Terraform Stacks Deployments Design Prompt
Design a Terraform Stacks (HCP) configuration that splits components from deployments, so one set of modules fans out across regions, accounts, and environments with orchestrated dependency ordering.
- Target user
- Platform engineers adopting HCP Terraform Stacks for multi-deployment fleets
- Difficulty
- Advanced
- Tools
- Claude, ChatGPT
The prompt
You are a Terraform Stacks specialist who has migrated sprawling per-environment root modules into clean `tfstack.hcl` / `tfdeploy.hcl` topologies. I will provide: - My current root-module layout (dirs per env/region, copy-pasted backends) - The set of regions, accounts, and environments I deploy to - Cross-component dependencies (network before cluster before workloads) - Auth model (OIDC roles per account) Your job: 1. **Components vs deployments** — explain the split crisply: components are the reusable building blocks in `tfstack.hcl`, deployments are the concrete instances in `tfdeploy.hcl`. Map my dirs onto this. 2. **Component graph** — define each `component` block, its `source`, `inputs`, and `providers`. Show how `component.network.outputs` feed `component.cluster` inputs so Stacks orders them automatically — no manual `depends_on` choreography. 3. **Deployments** — write `deployment "prod-us-east"` etc. blocks. Show `variables` per deployment and how to avoid duplication with `locals` and `store` blocks. 4. **Identity tokens** — wire `identity_token` + `deployment` provider auth so each deployment assumes the correct OIDC role; no static keys. 5. **Orchestration rules** — author `orchestrate "auto_approve"` and `orchestrate "replan"` rules so non-prod auto-applies and prod requires review; gate on `context.plan.changes`. 6. **Deferred changes** — explain how Stacks handles unknown counts (e.g., new region added to a `for_each` over deployments) via deferred actions, and when to expect a second plan. 7. **Rollout strategy** — order deployments (canary region first), and show how to pause the rest if the canary plan looks wrong. 8. **Migration path** — concrete steps to move existing state from per-env roots into Stacks deployments without recreating resources (state mapping, `removed` blocks in old roots). Output: (a) annotated `tfstack.hcl`, (b) `tfdeploy.hcl` with 4 deployments, (c) orchestration rules, (d) migration runbook, (e) a list of Stacks limitations to verify against current HCP docs before committing. Bias toward: automatic dependency ordering over manual wiring, least-privilege per deployment, and a reversible migration.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
Terraform Stacks Deferred Changes Planning Prompt
Plan and reason about deferred changes across Stack components so unknown-count expansions apply safely in dependency order
-
Terragrunt to Native Stacks Migration Prompt
Evaluate and plan a migration from a Terragrunt DRY setup to native Terraform Stacks (or OpenTofu stacks) — mapping `terragrunt.hcl` patterns, dependencies, and generate blocks onto first-class language features.
-
Terraform Aliased Provider Passing to Nested Modules Prompt
Wire aliased providers (multi-region, multi-account) down through nested module trees using explicit `configuration_aliases` and `providers = {}` maps instead of implicit inheritance.
-
Dynamic Multi-Instance Provider Configuration with for_each Prompt
Use for_each on provider configurations (Terraform 1.9+) to fan resources out across many accounts or regions without hand-written aliases
More Terraform prompts & error guides
Browse every Terraform prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.