Export and view preview results

This page describes how to export and review the results of a preview. A preview describes the actions to actuate a specific Terraform configuration. Before you create a new deployment or update a deployment, you can preview the deployment to verify what is planned to change.

If you have not yet created the preview that you want to view, see Preview a deployment.

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

Before you begin

  1. Enable Infra Manager.
  2. Ensure that you have the IAM permissions needed to export previews: roles/config.admin.

Export the results of the preview

To review the results of a preview, first export the results. Then, view the exported results using an appropriate tool.

To export a preview, its state must be SUCCEEDED or STALE. You can view the current state of a preview using the describe or list commands.

Export the results of a preview and save it locally using the following command:

gcloud infra-manager previews export projects/PROJECT_ID/locations/LOCATION/previews/PREVIEW_ID

Replace:

  • 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.
  • PREVIEW_ID: the preview identifier that you specify. See Preview name for details about constraints on the preview identifier.

View the results of the preview

The results are exported in two formats: the binary planfile, and the JSON representation. You can use either format to review the results. To view the results, use an appropriate tool for the format.

Review the binary planfile

To view the binary planfile:

  1. Ensure you have the Terraform CLI installed.

  2. Ensure that the Terraform configuration that you used to create the preview is present locally and initialized with terraform init.

  3. Print the proposed plan using terraform show.

Review the JSON representation

To view the JSON representation, you can use your IDE or tools like jq.

To enforce policy constraints you can use JSON representation with tools like Terraform vet.

What's next