Terraform
Update from beta to general availability
The GA release of Stacks introduces several new features and improvements.
Terraform CLI changes
During the Stacks beta, you could initialize your Stack using the terraform-stacks-cli
. The separate terraform-stacks-cli
is now deprecated. To provide a more unified experience, all Stacks commands are now in the main Terraform CLI as a new subcommand: terraform stacks
. You can now manage all of your Terraform Stack operations from a single tool, streamlining your workflow. To learn more, refer to the terraform stacks
CLI commands.
Language changes
The general availability release of Stacks introduced a few backward-incompatible syntax changes to the Stacks language:
- Syntax change for deployment groups and auto-approval:
- The
auto_approve
,orchestrate
, andreplan
blocks for orchestration rule are now deprecated. - The
auto_approve
block is replaced by a new auto_approve_checks argument on the deployment_group block. The newdeployment_group
syntax lets you define auto-approval rules directly within your custom deployment groups, giving you more granular control. Learn more about defining conditions for your deployment runs.
- The
- Stacks no longer support the
<NAME>.tfstack.hcl
file extension.- The new extension for configuring your Stack components is
<NAME>.tfcomponent.hcl
. The file name change better reflects the mental model of a component-based configuration.
- The new extension for configuring your Stack components is
Billing Changes
The Stacks public beta did not count toward your HCP Terraform organization's Resources Under Management (RUM). With the GA release, Stacks RUM is aggregated with your workspace RUM for billing purposes.
Billing Dashboard
The HCP Terraform usage page has been updated to reflect the new billing metrics, including:
- Billable Managed Resources displays the sum of your total Stacks and total workspace RUM.
- Total Applies displays the sum of your total Stacks and workspace applies.
- Applies this month displays the Stacks and workspace applies this month.
- Billable Stack Resources displays the sum of your total Stacks RUM.
For more information on billing, refer to the HCP Terraform pricing page.
Steps for migration
If you used Stacks during the public beta, you need to take a few steps to transition your existing configurations to the GA release.
Note
After the release of Stacks in general availability, your existing beta configurations and state history are no longer available.
Update your configuration files
Perform the following updates to your Stack configuration files to use the new tfcomponent.hcl
file extension and the new syntax for deployment groups and auto-approval rules:
- Rename all of your
<NAME>.tfstack.hcl
files to<NAME>.tfcomponent.hcl
. For example you could run the following command to rename your file:
$ mv my_stack.tfstack.hcl my_stack.tfcomponent.hcl
- Update your configuration files to use the new
deployment_group
syntax for auto-approval. For example, the following code snippet uses the deprecatedorchestrate
block:
orchestrate "auto_approve" "no_destroy" {
check {
condition = context.plan.changes.remove == 0
reason = "Plan destroys ${context.plan.changes.remove} resources."
}
}
You can rewrite your auto-approval rules using the deployment_auto_approve
block to define your rules, then attaching those rules to deployment groups using the auto_approve_checks
argument. The following example rewrites the auto_approve
rule using deployment groups:
deployments.tfdeploy.hcl
deployment "my_deployment" {
inputs = {
# ...
}
deployment_group = deployment_group.my_custom_group
}
deployment_group "my_custom_group" {
auto_approve_checks = [
deployment_auto_approve.no_destroy
]
}
deployment_auto_approve "no_destroy" {
check {
condition = context.plan.changes.remove == 0
reason = "Plan destroys ${context.plan.changes.remove} resources."
}
}
For more information about deployment groups and auto-approval rules, refer to Defining conditions for your deployment runs.
Fetch your configuration
Trigger a new configuration fetch for each of your Stacks. The fetching process pulls your configuration from your Version Control System (VCS) and reinitializes your Stack. You can do this by using the terraform stacks fetch
command in the new CLI, or by triggering a deployment run in the HCP Terraform UI.