Delete a deployment

This page describes how to delete an Infrastructure Manager deployment.

This page assumes you are familiar with Terraform. For details, see Terraform and Infrastructure Manager.

Before you begin

  1. Ensure Infra Manager is enabled.
  2. Ensure that you have the IAM permissions needed to create deployments: roles/config.admin.
  3. 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.
  4. 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.
  5. Identify the Infra Manager deployment to delete.
  6. Ensure that the service account has the IAM permissions needed to delete resources in the specified projects and locations.

Grant permissions specific to the configuration

To delete Google Cloud resources in a specific deployment, the service account that you use to call Infra Manager needs permissions that are specific to what you are deleting.

These permissions are in addition to the permissions needed to use the Infra Manager service.

For details about granting permissions for the Google Cloud resources and ensuring you have access to the needed projects, see Configure the service account.

Delete a deployment

When an Infra Manager deployment is created, Infra Manager stores metadata about the deployment, the Terraform configuration that is deployed, and the state file.

When you delete a deployment, you delete this metadata and files. You can also delete the resources provisioned by the deployment, or keep these resources.

Delete provisioned resources

To delete the deployment metadata and delete the provisioned resources:

  1. Optionally, list the resources provisioned by the deployment:

    gcloud infra-manager resources list projects/PROJECT_ID/locations/LOCATION/deployments/DEPLOYMENT_ID/revisions/REVISION_ID
    

    Replace the following:

    • PROJECT_ID: the project ID where Infrastructure Manager runs.
    • LOCATION: the location where Infra Manager runs. See Infrastructure Manager locations for the list of valid locations.
    • DEPLOYMENT_ID: the deployment identifier that you specify. See Deployment name for details about constraints on the deployment identifier.
    • REVISION_ID: the revision ID representing a specific revision of a deployment. See Deployment name for details about constraints on the revision identifier.
  2. Preview the deletion of the resources. For details, see Preview a deletion of a deployment.

  3. Delete the deployment and provisioned resources:

    gcloud infra-manager deployments delete projects/PROJECT_ID/locations/LOCATION/deployments/DEPLOYMENT_ID
    

    Replace the following:

    • PROJECT_ID: the project ID where Infrastructure Manager runs.
    • LOCATION: the location where Infra Manager runs. See Infrastructure Manager locations for the list of valid locations.
    • DEPLOYMENT_ID: the deployment identifier that you specify. See Deployment name for details about constraints on the deployment identifier.

Keep provisioned resources

You may want to delete the deployment and keep the Google Cloud resources that were provisioned by the deployment.

For example, you deploy a configuration from the Terraform blueprints and modules for Google Cloud. Once it's deployed, you want to manage the resources through the console, and not use Infrastructure as Code (IaC). In this case, you may want to delete the deployment as you don't have use for the deployment's metadata.

To delete the deployment metadata and keep the provisioned resources:

gcloud infra-manager deployments delete projects/PROJECT_ID/locations/LOCATION/deployments/DEPLOYMENT_ID \
    --delete-policy=abandon

Replace the following:

  • PROJECT_ID: the project ID where Infrastructure Manager runs.
  • LOCATION: the location where Infra Manager runs. See Infrastructure Manager locations for the list of valid locations.
  • DEPLOYMENT_ID: the deployment identifier that you specify. See Deployment name for details about constraints on the deployment identifier.

What's next