Terraform
Review deployment runs
Deployment runs are a combination of an individual configuration version and one of your Stack's deployments. As in the traditional Terraform workflow, HCP Terraform creates runs every time a new configuration version introduces potential changes for a deployment. To learn more about how deployment runs work, including how they update Stack deployment state, refer to Stack deployment runs.
You can also view, approve, or cancel deployment runs directly from the Terraform CLI, to learn more refer to the terraform stacks deployment-run
commands.
Requirements
To view a Stack and its deployment runs, you must also be a member of a team in your organization with one of the following permissions:
- Organization-level View all projects or higher
- Project-level Read or higher to view deployment runs
- Project-level Write or higher to interact with deployment runs
View a deployment
If you are not already on your Stack's deployment page, navigate to it:
- Sign in to HCP Terraform, and select the organization that contains your Stack.
- In the navigation menu, click Projects under Manage.
- Select the project containing your Stack.
- Select the Stack you want to review.
- Select Deployments in the side navigation.
A Stack's Deployments page displays a list of all of that Stack's deployments. Each deployment lists the latest available configuration version for that deployment.
Click View run history to view a list of all of the configuration versions a deployment has executed deployment runs for, and the status of each run. You can review the details of a deployment run by clicking on a specific configuration version.
View deployment runs
A deployment run is a combination of an individual configuration version and one of your Stack's deployments.
You can review the latest deployment run from the Deployments page by clicking on the configuration version number under Activity. You can also view deployment runs for specific versions on the Configurations page by selecting a version and clicking on the name of a specific deployment.
A deployment run consists of the steps that Terraform can perform to update that deployment to match the associated configuration version. All deployment run pages display the following information:
- The ID of the deployment run.
- The name of the associated deployment.
- The configuration version number associated with this deployment run.
- The status of the deployment run.
- If a deployment run was approve, the name of the approver, and any comment they left when approving.
- When HCP Terraform created the run.
- Any infrastructure resources the deployment run plans to create, update, or destroy.
- A button to Approve all plans for this configuration version, approving this deployment run and other associated runs for this configuration version.
- A button to Cancel run to discard this deployment run.
HCP Terraform stores the state of Stacks in files corresponding to each deployment of that Stack. After applying any plan, HCP Terraform displays a View state button next to each step of that plan to let you view a sanitized version of the state for the deployment at that step. To learn more about how state works for deployments, refer to State in Stacks.
If you have enabled debug logging for your Stack, you can download detailed logs of each step of your deployment run by expanding the Inspect dropdown.
Deployment run status
A deployment run can be in one of several states:
Status | Description |
---|---|
Plan: Queued | HCP Terraform is preparing to create a plan for this deployment. |
Plan: Started | HCP Terraform is starting to create a plan for a deployment. |
Plan: Running | HCP Terraform is creating a plan for a deployment. |
Plan: Pending operator | HCP Terraform created a plan for a deployment and is waiting for you to approve that plan. |
Apply: Queued | HCP Terraform is preparing to apply a plan for this deployment. |
Errored | The deployment run has encountered an error. Review the deployment run's errors to learn more. |
Approve plans
Like traditional Terraform plans, Stack deployment runs list the changes that occur if you approve that plan. Each deployment run lists its expected resource changes for that deployment, and you can review those changes to whether to apply a plan. You can manage each deployment plan independently, so any plans you approve only affect the current deployment you are interacting with.
To approve a deployment run's plan you can perform the following steps:
- On the Configurations page, click on a specific configuration version, then click on the ellipsis next to a deployment and select View deployment run.
- On the deployment run page, you can click Approve plan to approve the plan for this deployment, or Approve plan with comment to approve the plan and add a comment.
You can also approve a deployment run's plan from the Deployments page:
- On the Deployments page, click on the configuration version number under Activity.
- Click Approve plan to approve the plan for this deployment, or Approve plan with comment to approve the plan and add a comment.
To approve all of the deployment runs for a specific configuration version, you can do either of the following:
- Click Approve all plans on a deployment run to approve all pending plans for this configuration version across all deployments.
- On the Configurations page, click on a specific configuration version, then click on the ellipsis next to a specific deployment and click Approve all plans.
You can also view, approve, or cancel deployment runs directly from the Terraform CLI, to learn more refer to the terraform stacks deployment-run
commands.
Convergence checks
By default, each Stack has an auto_approve
rule named empty_plan
, which auto-approves a plan if it does not contain changes.
After applying any step in a plan, HCP Terraform automatically triggers a step called a convergence check. A convergence check is a replan to ensure components do not have any deferred changes. HCP Terraform continues to trigger new replan steps until the convergence check returns an empty plan, indicating that the deployment has reached convergence.
To learn more about deployment runs and their steps, refer to Stack deployment runs.
Deferred changes
Like with Terraform configuration files, HCP Terraform generates a dependency graph and creates resources defined in <NAME>.tfcomponent.hcl
and <NAME>.tfdeploy.hcl
files.
When you deploy a Stack with resources that depend on resources provisioned by other components in your stack, HCP Terraform recognizes the dependency between components and automatically defers the step in that plan until HCP Terraform can complete it successfully.
Hands-on: Complete the Manage Kubernetes workloads with stacks tutorial to create plans with deferred changes.
HCP Terraform notifies you in the UI if a plan contains deferred changes. Approving a plan with deferred changes makes HCP Terraform automatically create a follow-up plan to properly set up resources in the order of operations those resources require.