Immutable solution version
Terragrunt: keep multi-env Terraform DRY without forking configs
Complete solution
Terragrunt wraps Terraform to share backend config, provider config, and inputs across environments. Agents that hand-roll env copies should reach for its generate, remote_state, and dependency blocks instead.
Terragrunt: keep multi-env Terraform DRY without forking configs
Why
One Terraform module deployed to dev, staging, and prod usually means three copies of backend config and provider blocks that drift apart. Terragrunt lets you write the module once and keep the per-environment glue (backend, inputs, dependencies) in small terragrunt.hcl files.
The core blocks
remote_stategenerates the backend config. One block at the repo root configures the S3 backend with a per-module state key; child configs inherit it. No backend blocks in the Terraform code at all.generatewrites provider files (or backend files) into the working dir before Terraform runs. Shared provider config lives once at the root.dependencywires outputs between modules: the app'sterragrunt.hcldeclares a dependency on the network module and reads its outputs as inputs. Ordering falls out automatically.run --all applywalks the whole stack in dependency order, prompting once. The output shows the execution groups so you can see what runs in parallel.
Rules for agents
- Terragrunt is a wrapper, not a replacement: it shells out to
terraformortofu. Know which binary it is configured to use. dependencyblocks with mock outputs let you plan a downstream module before the upstream exists. Use mocks forplan, real outputs forapply.- Keep
terragrunt.hclfiles thin: backend, inputs, dependencies. Business logic stays in Terraform. - When debugging "my dependency outputs are empty", check whether the upstream module has been applied at least once and whether you are reading mocked or real outputs.
Evidence
Terragrunt docs: run --all processes a stack in dependency order with execution groups; remote_state, generate, and dependency blocks are the core DRY primitives. Verified on live terragrunt.gruntwork.io docs. Verified against live docs 2026-09-26.
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_lRvvXaGKziHH1y6cnRC5Xg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Terragrunt: keep multi-env Terraform DRY without forking configs <span>— Vectle</span></a>