Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Dokumen ini menjelaskan cara menghapus grup instance terkelola (MIG) yang tidak lagi Anda perlukan, sehingga Anda dapat berhenti membayar resource yang digunakannya.
Sebelum memulai
Jika Anda belum melakukannya, siapkan autentikasi.
Autentikasi adalah
proses yang digunakan untuk memverifikasi identitas Anda untuk mengakses Google Cloud layanan dan API.
Untuk menjalankan kode atau sampel dari lingkungan pengembangan lokal, Anda dapat melakukan autentikasi ke
Compute Engine dengan memilih salah satu opsi berikut:
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
Menginstal Google Cloud CLI.
Setelah penginstalan,
lakukan inisialisasi Google Cloud CLI dengan menjalankan perintah berikut:
Saat Anda menghapus grup instance terkelola, semua VM dalam grup tersebut akan dihapus. Jika Anda ingin mempertahankan VM mana pun, hapus VM terlebih dahulu untuk menghapus VM tersebut dari grup. Kemudian, hapus grup instance terkelola.
Disk dalam MIG hanya akan dihapus jika Anda telah menyetel properti hapus otomatis disk ke true saat menentukan disk di template instance MIG. Jika properti hapus otomatis disk disetel ke false, Anda dapat membersihkan disk secara manual saat tidak lagi membutuhkannya.
Saat Anda menghapus grup instance terkelola dan instance-nya dengan menggunakan
Google Cloud console atau gcloud CLI,
setiap autoscaler yang terpasang akan terhapus secara otomatis. Namun, jika menggunakan
REST, Anda
harus mengirimkan permintaan terpisah terlebih dahulu untuk menghapus autoscaler yang terpasang dengan
metode autoscalers.delete
atau
metode regionAutoscalers.delete.
Jika grup instance terkelola dihapus terlebih dahulu, Anda masih dapat menghapus autoscaler yang terpasang menggunakan REST.
Untuk setiap disk, Anda juga dapat mengganti properti hapus otomatis untuk menentukan apakah disk harus dihapus saat instance-nya yang terkait dihapus.
Izin yang diperlukan untuk langkah ini
Untuk melakukan tugas ini, Anda harus memiliki izin berikut:
compute.instanceGroupManagers.delete pada grup instance terkelola
Konsol
Di konsol Google Cloud , buka halaman Instance groups.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)"]]