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
- Enable Infra Manager .
- Ensure that you have the IAM permissions needed to export
previews:
roles/config.admin
. - Create a preview deployment .
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 plan file , 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 plan file
To view the binary plan file:
-
Verify that you have the Terraform CLI installed.
-
Verify that the Terraform configuration that you used to create the preview is present locally and initialized with
terraform init
. -
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 .
View resource change and drift details
You can use previews to view resource drift for your deployment. Viewing resource drift for your deployments is useful to verify that changes to your configurations are intended, and to summarize how your deployment will change when your deployment is updated with a particular preview.
When you create a preview, you use the Infra Manager API to view changes to your resources as you update your deployments.
View resource drift
To view a list of resource drifts of a preview deployment:
gcloud infra-manager resource-drifts list --preview=projects/ PROJECT_ID
/locations/ LOCATION
/previews/ PREVIEW_ID
Replace:
- PROJECT_ID : The identifier of the Google Cloud project where your preview deployment is located.
- LOCATION : The region or zone of your preview deployment.
- PREVIEW_ID : The identifier of your preview deployment.
View details of a drift
To view details of a resource drift from a preview deployment:
gcloud infra-manager resource-drifts describe projects/ PROJECT_ID
/locations/ LOCATION
/previews/ PREVIEW_ID
/resourceDrifts/ RESOURCE_DRIFT_ID
Replace:
- PROJECT_ID : The identifier of the Google Cloud project where your preview deployment is located.
- LOCATION : The region or zone of your preview deployment.
- PREVIEW_ID : The identifier of your preview deployment.
- RESOURCE_DRIFT_ID : The identifier of your drift.
Preview resource changes
You can use previews to check how your resources will change if you update a deployment from your preview.
View resource changes
To view a list of resource changes of a preview deployment:
gcloud infra-manager resource-changes list --preview=projects/ PROJECT_ID
/locations/ LOCATION
/previews/ PREVIEW_ID
Replace:
- PROJECT_ID : The identifier of the Google Cloud project where your preview deployment is located.
- LOCATION : The region or zone of your preview deployment.
- PREVIEW_ID : The identifier of your preview deployment.
View details of a resource change
To view details of a resource change from a preview deployment:
gcloud infra-manager resource-changes describe projects/ PROJECT_ID
/locations/ LOCATION
/previews/ PREVIEW_ID
/resourceChanges/ RESOURCE_CHANGE_ID
Replace:
- PROJECT_ID : The identifier of the Google Cloud project where your preview deployment is located.
- LOCATION : The region or zone of your preview deployment.
- PREVIEW_ID : The identifier of your preview deployment.
- RESOURCE_CHANGE_ID : The identifier of your resource change.