Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Este documento descreve como excluir um
grupo de instâncias gerenciadas (MIG)
que não é mais necessário para que você possa parar de pagar pelos recursos que ele usa.
Antes de começar
Configure a autenticação, caso ainda não tenha feito isso.
A autenticação é
o processo de verificação da sua identidade para acesso a serviços e APIs do Google Cloud .
Para executar códigos ou amostras de um ambiente de desenvolvimento local, autentique-se no
Compute Engine selecionando uma das seguintes opções:
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
Instale a CLI do Google Cloud.
Após a instalação,
inicialize a Google Cloud CLI executando o seguinte comando:
Para mais informações, consulte
Autenticar para usar REST
na documentação de autenticação do Google Cloud .
Excluir um MIG
Quando você exclui um grupo de instâncias gerenciadas, todas as VMs no grupo são
excluídas. Se você quiser manter alguma das VMs,
abandone as VMs
primeiro para removê-las do grupo. Em seguida, exclua o grupo de instâncias gerenciadas.
Os discos em um MIG serão excluídos somente se você tiver definido a propriedade de exclusão automática do disco como verdadeiro ao definir os discos no modelo de instância do MIG. Se a propriedade de exclusão automática de um disco estiver definida como falsa, será possível limpá-los manualmente quando não precisar mais deles.
Quando você exclui um grupo gerenciado de instâncias e as respectivas instâncias usando o
Google Cloud console ou a CLI gcloud,
todos os escalonadores automáticos anexados são excluídos automaticamente. No entanto, se você usar a REST, primeiro envie uma solicitação separada com o método autoscalers.delete ou o método regionAutoscalers.delete para excluir qualquer escalonador automático anexado.
Se você excluir o grupo gerenciado de instâncias primeiro, ainda será possível excluir o escalonador automático anexado usando a REST.
Também é possível modificar a propriedade de exclusão automática de cada disco para especificar se ele precisa ser excluído ou não quando sua instância associada for excluída.
Permissões exigidas para a tarefa
Para executar esta tarefa, é necessário ter
permissões:
compute.instanceGroupManagers.delete no grupo de instâncias gerenciadas
Console
No console Google Cloud , acesse a página Grupos de instâncias.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-19 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)"]]