Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Ce document explique comment supprimer un groupe d'instances géré (MIG) dont vous n'avez plus besoin afin que vous puissiez cesser de payer les ressources qu'il utilise.
Avant de commencer
Si ce n'est pas déjà fait, configurez l'authentification.
L'authentification valide votre identité pour accéder aux services et aux API Google Cloud . Pour exécuter du code ou des exemples depuis un environnement de développement local, vous pouvez vous authentifier auprès de Compute Engine en sélectionnant l'une des options suivantes :
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
Installez la Google Cloud CLI.
Une fois que la Google Cloud CLI est installée, initialisez-la en exécutant la commande suivante :
Pour utiliser les exemples API REST de cette page dans un environnement de développement local, vous devez utiliser les identifiants que vous fournissez à la gcloud CLI.
Installez la Google Cloud CLI.
Une fois que la Google Cloud CLI est installée, initialisez-la en exécutant la commande suivante :
Pour en savoir plus, consultez la section S'authentifier pour utiliser REST dans la documentation sur l'authentification Google Cloud .
Supprimer un MIG
Lorsque vous supprimez un groupe d'instances géré, toutes les VM du groupe sont supprimées. Si vous souhaitez conserver certaines VM, commencez par abandonner les VM applicables afin de les retirer du groupe. Supprimez ensuite le groupe d'instances géré.
Les disques d'un MIG ne sont supprimés que si vous avez défini leur propriété de suppression automatique sur "true" lors de la définition des disques dans le modèle d'instance du MIG. Si la propriété de suppression automatique d'un disque est définie sur "false", vous pouvez nettoyer manuellement les disques lorsque vous n'en avez plus besoin.
Lorsque vous supprimez un groupe d'instances géré et ses instances à l'aide deGoogle Cloud console ou de gcloud CLI, tous les autoscalers associés sont automatiquement supprimés. Néanmoins, si vous utilisez REST, vous devez d'abord envoyer des requêtes distinctes pour supprimer tous les autoscalers associés à la méthode autoscalers.delete ou à la méthode regionAutoscalers.delete.
Si vous supprimez d'abord le groupe d'instances géré, vous pouvez toujours supprimer l'autoscaler associé à l'aide de REST.
Pour chaque disque, vous pouvez également ignorer la propriété de suppression automatique et indiquer si le disque doit être supprimé ou non lorsque l'instance associée est elle-même supprimée.
Autorisations requises pour cette tâche
Pour effectuer cette tâche, vous devez disposer des autorisations suivantes :
compute.instanceGroupManagers.delete sur le groupe d'instances géré
Console
Dans la console Google Cloud , accédez à la page Groupes d'instances.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)"]]