Pastikan Anda memiliki izin IAM yang diperlukan untuk membuat deployment: roles/config.admin.
Pastikan akun layanan yang terakhir digunakan untuk membuat atau memperbarui deployment masih valid. Infra Manager menggunakan akun layanan ini untuk menghapus deployment.
Untuk mengetahui detail tentang cara mengonfigurasi akun layanan, termasuk menyiapkan izin yang diperlukan, lihat Mengonfigurasi akun layanan.
Untuk menentukan akun layanan yang terakhir digunakan untuk deployment, lihat Melihat status revisi.
Pastikan konfigurasi Terraform yang digunakan Infra Manager untuk membuat atau memperbarui deployment masih valid. Infra Manager menggunakan
konfigurasi ini untuk menghapus deployment.
Identifikasi deployment Infra Manager yang akan dihapus.
Pastikan akun layanan memiliki izin IAM
yang diperlukan untuk menghapus resource di project dan lokasi yang ditentukan.
Memberikan izin khusus untuk konfigurasi
Untuk menghapus resource Google Cloud dalam deployment tertentu, akun layanan yang Anda gunakan untuk memanggil Infra Manager memerlukan izin yang spesifik untuk resource yang Anda hapus.
Izin ini merupakan tambahan dari izin yang diperlukan untuk menggunakan
layanan Infra Manager.
Untuk mengetahui detail tentang cara memberikan izin untuk resource Google Cloud dan memastikan Anda memiliki akses ke project yang diperlukan, lihat
Mengonfigurasi akun layanan.
Menghapus deployment
Saat deployment Infra Manager dibuat, Infra Manager
akan menyimpan metadata tentang deployment, konfigurasi Terraform yang
di-deploy, dan file status.
Saat menghapus deployment, Anda akan menghapus metadata dan file ini. Anda juga dapat menghapus resource yang disediakan oleh deployment, atau mempertahankan resource ini.
Menghapus resource yang disediakan
Untuk menghapus metadata deployment dan menghapus resource yang disediakan:
Secara opsional, cantumkan resource yang disediakan oleh deployment:
PROJECT_ID: project ID tempat Infrastructure Manager berjalan.
LOCATION: lokasi tempat Infra Manager
berjalan. Lihat Lokasi Infrastructure Manager untuk mengetahui daftar lokasi yang valid.
DEPLOYMENT_ID: ID deployment yang Anda tentukan. Lihat
Nama deployment
untuk mengetahui detail tentang batasan pada ID deployment.
Mempertahankan resource yang disediakan
Anda dapat menghapus deployment dan menyimpan resource Google Cloud yang disediakan oleh deployment.
Misalnya, Anda men-deploy konfigurasi dari
blueprint dan modul Terraform untuk Google Cloud. Setelah di-deploy, Anda ingin mengelola resource
melalui konsol, dan tidak menggunakan Infrastructure as Code (IaC). Dalam hal ini,
Anda dapat menghapus deployment karena tidak memerlukan
metadata deployment.
Untuk menghapus metadata deployment dan mempertahankan resource yang disediakan:
[[["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 details the process of deleting an Infrastructure Manager deployment, which involves removing the associated metadata and optionally, the provisioned resources.\u003c/p\u003e\n"],["\u003cp\u003eBefore deleting, ensure Infrastructure Manager is enabled, you have the necessary IAM permissions, and the service account and Terraform configuration used for the deployment are valid.\u003c/p\u003e\n"],["\u003cp\u003eYou can choose to delete the deployment along with all provisioned Google Cloud resources, or opt to retain the resources while only deleting the deployment metadata.\u003c/p\u003e\n"],["\u003cp\u003eTo delete both the deployment and provisioned resources, use the \u003ccode\u003egcloud infra-manager deployments delete\u003c/code\u003e command, and for keeping the resources, use the same command with the \u003ccode\u003e--delete-policy=abandon\u003c/code\u003e flag.\u003c/p\u003e\n"],["\u003cp\u003eThe service account used for the operation needs permissions for the Infrastructure Manager service and to delete resources within the specified Google Cloud project and location, as well as a valid Terraform configuration.\u003c/p\u003e\n"]]],[],null,["# Delete a deployment\n\nThis page describes how to delete an Infrastructure Manager deployment.\n\nThis page assumes you are familiar with Terraform. For details, see\n[Terraform and Infrastructure Manager](/infrastructure-manager/docs/terraform).\n\nBefore you begin\n----------------\n\n1. Ensure [Infra Manager is enabled](/infrastructure-manager/docs/enable-service).\n2. Ensure that you have the IAM permissions needed to create deployments: `roles/config.admin`.\n3. Ensure the service account that was last used to create or update the deployment is still valid. Infra Manager uses this service account to delete the deployment.\n - For details about configuring the service account, including setting up required permissions, see [Configure the service account](/infrastructure-manager/docs/configure-service-account).\n - To determine the service account that was last used for the deployment, see [View the state of a revision](/infrastructure-manager/docs/view-deployments#revision-details).\n4. Ensure the Terraform configuration that Infra Manager used to create or update the deployment is still valid. Infra Manager uses this configuration to delete the deployment.\n5. Identify the Infra Manager deployment to delete.\n6. Ensure that the service account has the IAM permissions needed to delete resources in the specified projects and locations.\n\nGrant permissions specific to the configuration\n-----------------------------------------------\n\nTo delete Google Cloud resources in a specific deployment, the service\naccount that you use to call Infra Manager needs\npermissions that are specific to what you are deleting.\n\nThese permissions are in addition to the permissions needed to use the\nInfra Manager service.\n\nFor details about granting permissions for the Google Cloud resources and\nensuring you have access to the needed projects, see\n[Configure the service account](/infrastructure-manager/docs/configure-service-account).\n\nDelete a deployment\n-------------------\n\nWhen an Infra Manager deployment is created, Infra Manager\nstores metadata about the deployment, the Terraform configuration that is\ndeployed, and the state file.\n\nWhen you delete a deployment, you delete this metadata and files. You can\nalso delete the resources provisioned by the deployment, or keep these\nresources.\n\n### Delete provisioned resources\n\n| **Caution:** Deleting Google Cloud resources can cause unrecoverable data loss. Re-deploying the configuration will not restore data.\n\nTo delete the deployment metadata and delete the provisioned resources:\n\n1. Optionally, list the resources provisioned by the deployment:\n\n gcloud infra-manager resources list projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/deployments/\u003cvar translate=\"no\"\u003eDEPLOYMENT_ID\u003c/var\u003e/revisions/\u003cvar translate=\"no\"\u003eREVISION_ID\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID where Infrastructure Manager runs.\n - \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the location where Infra Manager runs. See [Infrastructure Manager locations](/infrastructure-manager/docs/locations) for the list of valid locations.\n - \u003cvar translate=\"no\"\u003eDEPLOYMENT_ID\u003c/var\u003e: the deployment identifier that you specify. See [Deployment name](/infrastructure-manager/docs/overview#deployments) for details about constraints on the deployment identifier.\n - \u003cvar translate=\"no\"\u003eREVISION_ID\u003c/var\u003e: the revision ID representing a specific revision of a deployment. See [Deployment name](/infrastructure-manager/docs/overview#deployments) for details about constraints on the revision identifier.\n2. Preview the deletion of the resources. For details, see\n [Preview a deletion of a deployment](/infrastructure-manager/docs/preview-deployment-deletion).\n\n3. Delete the deployment and provisioned resources:\n\n gcloud infra-manager deployments delete projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/deployments/\u003cvar translate=\"no\"\u003eDEPLOYMENT_ID\u003c/var\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID where Infrastructure Manager runs.\n - \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the location where Infra Manager runs. See [Infrastructure Manager locations](/infrastructure-manager/docs/locations) for the list of valid locations.\n - \u003cvar translate=\"no\"\u003eDEPLOYMENT_ID\u003c/var\u003e: the deployment identifier that you specify. See [Deployment name](/infrastructure-manager/docs/overview#deployments) for details about constraints on the deployment identifier.\n\n### Keep provisioned resources\n\nYou may want to delete the deployment and keep the Google Cloud resources\nthat were provisioned by the deployment.\n\nFor example, you deploy a configuration from the\n[Terraform blueprints and modules for Google Cloud](/docs/terraform/blueprints/terraform-blueprints). Once it's deployed, you want to manage the resources\nthrough the console, and not use Infrastructure as Code (IaC). In this case,\nyou may want to delete the deployment as you don't have use for the\ndeployment's metadata.\n| **Note:** After you delete the deployment, Infra Manager is not able to identify or manage the Google Cloud resources that are kept.\n\nTo delete the deployment metadata and keep the provisioned resources: \n\n gcloud infra-manager deployments delete projects/\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e/locations/\u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e/deployments/\u003cvar translate=\"no\"\u003eDEPLOYMENT_ID\u003c/var\u003e \\\n --delete-policy=abandon\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: the project ID where Infrastructure Manager runs.\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: the location where Infra Manager runs. See [Infrastructure Manager locations](/infrastructure-manager/docs/locations) for the list of valid locations.\n- \u003cvar translate=\"no\"\u003eDEPLOYMENT_ID\u003c/var\u003e: the deployment identifier that you specify. See [Deployment name](/infrastructure-manager/docs/overview#deployments) for details about constraints on the deployment identifier.\n\nWhat's next\n-----------\n\n- Learn more about [Terraform with Google Cloud](/docs/terraform).\n- [View the state of a deployment](/infrastructure-manager/docs/view-deployments).\n- [View resources deployed](/infrastructure-manager/docs/view-resources)."]]