Mantieni tutto organizzato con le raccolte
Salva e classifica i contenuti in base alle tue preferenze.
Questo documento descrive come eliminare un gruppo di istanze gestite (MIG) di cui non hai più bisogno in modo da poter smettere di pagare per le risorse che utilizza.
Prima di iniziare
Se non l'hai ancora fatto, configura l'autenticazione.
L'autenticazione è il processo mediante il quale la tua identità viene verificata per l'accesso a servizi e API di Google Cloud .
Per eseguire codice o esempi da un ambiente di sviluppo locale, puoi autenticarti su
Compute Engine selezionando una delle seguenti opzioni:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and
APIs, you don't need to set up authentication.
gcloud
Install the Google Cloud CLI.
After installation,
initialize the Google Cloud CLI by running the following command:
Quando elimini un gruppo di istanze gestite, tutte le VM al suo interno vengono eliminate. Se vuoi conservare una o più VM, abbandonale prima per rimuoverle dal gruppo. Poi elimina il gruppo di istanze gestite.
I dischi in un MIG vengono eliminati solo se hai impostato la proprietà di eliminazione automatica del disco su true quando hai definito i dischi nel modello di istanza del MIG. Se la proprietà di eliminazione automatica di un disco è impostata su false, puoi pulire manualmente i dischi quando non ti servono più.
Quando elimini un gruppo di istanze gestite e le relative istanze utilizzando laGoogle Cloud console o gcloud CLI, qualsiasi gestore della scalabilità automatica associato viene eliminato automaticamente. Tuttavia, se utilizzi REST, devi prima inviare una richiesta separata per eliminare un eventuale gestore della scalabilità automatica collegato con il metodo autoscalers.delete o con il metodo regionAutoscalers.delete.
Se elimini per primo il gruppo di istanze gestite, puoi comunque eliminare il gestore della scalabilità automatica collegato utilizzando REST.
Per ogni disco, puoi anche ignorare la proprietà di eliminazione automatica per specificare se il disco deve essere eliminato quando viene eliminata l'istanza associata.
Autorizzazioni richieste per questa attività
Per eseguire questa attività, devi disporre delle seguenti autorizzazioni:
compute.instanceGroupManagers.delete sul gruppo di istanze gestite
Console
Nella console Google Cloud , vai alla pagina Gruppi di istanze.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 2025-09-04 UTC."],[[["\u003cp\u003eThis guide explains how to delete a managed instance group (MIG) and its associated resources to avoid incurring unnecessary costs.\u003c/p\u003e\n"],["\u003cp\u003eDeleting a MIG will remove all virtual machines (VMs) within it, unless you choose to abandon specific VMs beforehand.\u003c/p\u003e\n"],["\u003cp\u003eDisks within the MIG will only be deleted automatically if their auto-delete property was set to true during the MIG's template configuration, otherwise manual deletion is necessary.\u003c/p\u003e\n"],["\u003cp\u003eIf a MIG is associated with a load balancer's backend service, the backend service must be removed before deleting the MIG, and any autoscalers attached to the MIG must be deleted separately when using the REST API.\u003c/p\u003e\n"],["\u003cp\u003eThe process can be done using the Google Cloud Console, gcloud CLI, or REST API, each with specific instructions and requirements.\u003c/p\u003e\n"]]],[],null,["# Delete a MIG\n\n*** ** * ** ***\n\nThis document describes how to delete a\n[managed instance group (MIG)](/compute/docs/instance-groups#managed_instance_groups)\nthat you no longer need so you can stop paying for the resources it uses.\n\nBefore you begin\n----------------\n\n- If you haven't already, set up [authentication](/compute/docs/authentication). Authentication verifies your identity for access to Google Cloud services and APIs. To run code or samples from a local development environment, you can authenticate to Compute Engine by selecting one of the following options:\n\n Select the tab for how you plan to use the samples on this page: \n\n ### Console\n\n\n When you use the Google Cloud console to access Google Cloud services and\n APIs, you don't need to set up authentication.\n\n ### gcloud\n\n 1.\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n After installation,\n [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command:\n\n ```bash\n gcloud init\n ```\n\n\n If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n 2. [Set a default region and zone](/compute/docs/gcloud-compute#set_default_zone_and_region_in_your_local_client).\n\n ### REST\n\n\n To use the REST API samples on this page in a local development environment, you use the\n credentials you provide to the gcloud CLI.\n 1. [Install](/sdk/docs/install) the Google Cloud CLI. After installation, [initialize](/sdk/docs/initializing) the Google Cloud CLI by running the following command: \n\n ```bash\n gcloud init\n ```\n 2. If you're using an external identity provider (IdP), you must first [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n\n For more information, see\n [Authenticate for using REST](/docs/authentication/rest)\n in the Google Cloud authentication documentation.\n\nDelete a MIG\n------------\n\nWhen you delete a managed instance group, all VMs in the group are\ndeleted. If you want to keep any of the VMs,\n[abandon the VMs](/compute/docs/instance-groups/add-remove-vms-in-mig#abandoning_instances)\nfirst to remove those VMs from the group. Then, delete the managed instance\ngroup.\n\nThe disks in a MIG are deleted only if you had set the disk's auto-delete\nproperty to true when defining the disks in the MIG's instance template. If a\ndisk's auto-delete property is set to false, then you can manually clean up the\ndisks when you no longer need them.\n| **Note:** You cannot delete an instance group if it is being used by a load balancer's [backend service](/compute/docs/load-balancing/http/backend-service). [Remove the backend service](/sdk/gcloud/reference/compute/backend-services/remove-backend) before deleting the instance group.\n\nWhen you delete a managed instance group and its instances by using the\n[Google Cloud console](https://console.cloud.google.com/) or the [gcloud CLI](/compute/docs/gcloud-compute),\nany attached autoscaler is automatically deleted. However, if you use the\n[REST](/compute/docs/reference/latest/instanceGroupManagers), you\nmust first issue a separate request to delete any attached autoscaler with the\n[`autoscalers.delete` method](/compute/docs/reference/rest/v1/autoscalers/delete)\nor\n[`regionAutoscalers.delete` method](/compute/docs/reference/rest/v1/regionAutoscalers/delete).\nIf you happen to delete the managed instance group first, you can still delete\nthe attached autoscaler using REST.\n\nFor each disk, you can also override the auto-delete property to specify whether\nthe disk should be deleted when its associated instance is deleted.\n\n#### Permissions required for this task\n\nTo perform this task, you must have the following\n[permissions](/iam/docs/overview#permissions):\n\n\n- `compute.instanceGroupManagers.delete` on the managed instance group \n\n### Console\n\n1. In the Google Cloud console, go to the **Instance groups** page.\n\n [Go to Instance groups](https://console.cloud.google.com/compute/instanceGroups)\n2. Select one or more groups on the list that you want to delete.\n\n3. Click **Delete** to delete the group and all of the VMs in the\n managed instance group.\n\n### gcloud\n\nUse the\n[`delete` command](/sdk/gcloud/reference/compute/instance-groups/managed/delete). \n\n```\ngcloud compute instance-groups managed delete INSTANCE_GROUP_NAME \\\n --zone ZONE\n```\n\n### REST\n\nCall the `delete` method for a\n[zonal](/compute/docs/reference/rest/v1/instanceGroupManagers/delete)\nor\n[regional](/compute/docs/reference/rest/v1/regionInstanceGroupManagers/delete)\nMIG resource. If the MIG has an attached autoscaler, you must first delete\nthe autoscaler using the [`autoscalers.delete` method](/compute/docs/reference/rest/v1/autoscalers/delete)\nor [`regionAutoscalers.delete` method](/compute/docs/reference/rest/v1/regionAutoscalers/delete). \n\n```\nDELETE https://compute.googleapis.com/compute/v1/projects/PROJECT_ID/zones/ZONE/instanceGroupManagers/INSTANCE_GROUP_NAME\n```\n\nIf the instance group is a regional managed instance group, replace\n`zones/`\u003cvar translate=\"no\"\u003eZONE\u003c/var\u003e with `regions/`\u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e.\n\nWhat's next\n-----------\n\n- Learn about [Getting, listing, and deleting instance templates](/compute/docs/instance-templates/get-list-delete-instance-templates)"]]