This page describes how to use Infrastructure Manager to preview the deletion of an
existing deployment.

A preview describes the actions to actuate a specific Terraform configuration.
Before you delete a deployment, you can use a preview to verify the resources
that are planned to be deleted.

A preview does not delete any provisioned resources. To delete a deployment,
including deleting provisioned resources, see
[Delete deployments](https://docs.cloud.google.com/infrastructure-manager/docs/delete-deployments.md.txt).

A preview executes the `Terraform plan` command. This page assumes you are
familiar with Terraform. For details, see
[Terraform and Infrastructure Manager](https://docs.cloud.google.com/infrastructure-manager/docs/infra-manager-terraform.md.txt).

## Before you begin

1. [Enable Infra Manager](https://docs.cloud.google.com/infrastructure-manager/docs/enable-service.md.txt).
2. Ensure that you have the IAM permissions needed to create previews: `roles/config.admin`.
3. Ensure you have a service account with the needed permissions. For details, see [Configure the service account](https://docs.cloud.google.com/infrastructure-manager/docs/configure-service-account.md.txt).
4. Identify the Terraform configuration to preview. Ensure this Terraform configuration complies with the [constraints](https://docs.cloud.google.com/infrastructure-manager/docs/terraform#constraints), including that the configuration does not contain sensitive data.
5. If you want to store the Terraform configuration in a storage bucket, ensure
   the Terraform configuration is uploaded to a Cloud Storage bucket. See
   [Upload a configuration to a storage bucket](https://docs.cloud.google.com/infrastructure-manager/docs/upload-terraform-configuration.md.txt)
   for more details.

   A storage bucket lets you control access to the configuration. You
   can also deploy a Terraform configuration that is stored in a
   public Git repository, or stored on your
   local machine.

## Preview the deletion of a deployment

Before you delete a deployment, you can preview and review the deletion.

To preview the deletion of a deployment:

    gcloud infra-manager previews create --preview-mode DELETE --deployment=projects/PROJECT_ID/locations/LOCATION/previews/DEPLOYMENT_ID \
        --service-account projects/SERVICE_ACCOUNT_PROJECT_ID/serviceAccounts/SERVICE_ACCOUNT \

Replace:

- <var translate="no">PROJECT_ID</var> is the project ID where Infrastructure Manager runs.
- <var translate="no">LOCATION</var> is the location where Infra Manager runs. See [Infrastructure Manager locations](https://docs.cloud.google.com/infrastructure-manager/docs/locations.md.txt) for the list of valid locations.
- <var translate="no">PREVIEW_ID</var> is the preview identifier that you specify. See [Preview name](https://docs.cloud.google.com/infrastructure-manager/docs/deployments-revisions.md.txt#preview_name) for details about constraints on the preview identifier.
- <var translate="no">SERVICE_ACCOUNT</var> is the name of the service account you use to call Infra Manager.
- <var translate="no">SERVICE_ACCOUNT_PROJECT_ID</var> is the project ID of the service account. It's common for this to be the same project where Infra Manager runs.
- <var translate="no">DEPLOYMENT_ID</var> is the deployment identifier of the deployment you want to update.

Now that you have created a preview, you can
[export and view the results](https://docs.cloud.google.com/infrastructure-manager/docs/export-view-preview-results.md.txt)
to review the plan for the deployment.

For more information about deleting deployments, see
[Delete a deployment](https://docs.cloud.google.com/infrastructure-manager/docs/delete-deployments.md.txt).

## What's next

- [Export and view preview results](https://docs.cloud.google.com/infrastructure-manager/docs/export-view-preview-results.md.txt)
- [Delete a deployment](https://docs.cloud.google.com/infrastructure-manager/docs/delete-deployments.md.txt).
- [Create a new preview](https://docs.cloud.google.com/infrastructure-manager/docs/preview-deployment.md.txt).
- [Automate deployments](https://docs.cloud.google.com/infrastructure-manager/docs/automate-git.md.txt).
- Learn more about [Terraform with Infra Manager](https://docs.cloud.google.com/infrastructure-manager/docs/infra-manager-terraform.md.txt).