Stacks components and deployments
One blueprint, several deployments
An HCP Terraform Stack organizes related infrastructure modules into components and repeats the group using deployment inputs. Imagine a catalogue application with a network and service that need coordinated changes in development and testing. A Stack gives those environments a shared configuration design without requiring them to share a state file.
Illustrative Stack: cataloguecomponents: network -> service deployment dev: region A, capacity 1, isolated state D deployment test: region B, capacity 2, isolated state TOne configuration revision; separate deployment progress.Each deployment tracks its own progress and state. That separation does not guarantee distinct cloud accounts or permissions: design those boundaries separately. A conventional root module uses module calls in .tf files; a Stack introduces a different top-level grammar. HCP workspaces and Stacks can coexist and neither is simply a renamed CLI workspace. Terragrunt stacks are a separate tool and grammar.
Define components and inputs
Use .tfcomponent.hcl files for the blueprint. A component refers to a Terraform module and supplies its inputs; the module still uses ordinary Terraform configuration. This static illustration assumes a local module with a matching string input. It omits module implementation and is not a deployable Stack.
variable "environment" { type = string}component "catalogue" { source = "./modules/catalogue" inputs = { environment = var.environment }}The component declaration connects an input of the Stack to an input of the module. For external providers, declare requirements and provider configurations at Stack level and map them into components. Stack provider authentication has its own rules, including deployment identity tokens where supported. Do not copy a conventional root provider block verbatim. Component and deployment expressions support restricted function sets; verify each function.
Repeat the blueprint
Write .tfdeploy.hcl files to describe instances of the blueprint. Each deployment supplies a value for the same environment variable.
deployment "dev" { inputs = { environment = "dev" }}deployment "test" { inputs = { environment = "test" }}The result is a proposed dev deployment and a test deployment, not two module instances inside one root state. Deployment groups can coordinate settings and approval rules. Explicitly review the intended targets and identity scopes. Upstream inputs and published outputs can connect Stacks within a project, but create an interface and trust boundary that needs ownership and change control.
Deferred planning and convergence
Suppose the service needs an endpoint that does not exist until the network component is created. Stacks can defer eligible dependent changes and produce follow-up plans after earlier changes apply. A deployment run can therefore involve multiple plan/apply cycles.
Synthetic run for revision r7plan 1: create network; service deferredapply 1: network availableplan 2: create service using endpointapply 2: service createdplan 3: empty -> configuration convergenceThis is a fictional progression, not guaranteed provider behavior. An empty plan means no remaining planned changes at that point; test actual service health separately. A configuration-version record marked completed is not proof every deployment is converged. Review each plan and do not assume one approval necessarily covers every subsequent change.
Validate and control rollout
Current documentation describes the terraform stacks CLI plugin for Terraform 1.13 and later, with commands such as terraform stacks init, validate and fmt. Treat initialization as dependency installation and review plugin provenance first. The old beta CLI is not the current workflow. HCP Terraform handles deployment runs; check current entitlement and version, and separately verify Terraform Enterprise release support. Official pages consulted disagree about the maximum deployment count (20 versus 500); do not use either as a planning guarantee without checking the actual service and applicable release. No hosted run or CLI validation is performed here. Use dev as an early review stage, then require explicit evidence of convergence and application checks before expanding a rollout. Auto-approval conditions should be narrow and tested, not a bypass for review.
Practice and next step
Draw the two-deployment architecture, identify separate states and mark which plan is deferred. Use the offline cases to decide whether rollout evidence is complete. Reference: terraform-concept-stacks-components-and-deployments. Read https://developer.hashicorp.com/terraform/language/stacks/component/config and https://developer.hashicorp.com/terraform/cloud-docs/stacks/deploy/runs.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Stacks components and deployments — knowledge check
Review Stack deployments, actions and discovery decisions.
What does a Stack deployment represent?
Which file defines Stack components?
What does a deferred change indicate?
What does an empty convergence plan establish?
What should you do when official deployment limits conflict?