skip to content

Your team runs about forty Terraform root modules with hand-copied backend and provider blocks. How would you decide whether to adopt Terragrunt, and what lock-in would you accept?

level: principalimportance: should knowfreq 33%

answer

  1. repetition versus a second tool
  2. do the roots really depend?
  3. state stays ordinary
  4. orchestration is the sticky part
  5. write the exit first

basics

~20 s

Adopt Terragrunt when repetition and ordering across many similar roots cost more than a second tool; keep plain root modules and CI when roots are few or independent. The lock-in sits in orchestration and configuration, not in state.

solid answer

~40 s

I would judge it on how many roots are near-identical, how much real ordering and output-passing crosses them, and whether someone will own the extra layer. Forty hand-copied roots lean towards Terragrunt: `root.hcl` removes the repeated blocks and `dependency` plus `run --all` handle ordering. The costs are a second CLI and config language, debugging through `.terragrunt-cache`, traps such as mock outputs, and a support table that can trail Terraform. I accept that lock-in because modules stay ordinary and `remote_state` fills in a normal backend, so state need not move on exit. What is sticky is `dependency` and run order, which CI would have to own. I would pilot one environment and write the exit plan before committing.

go deeper

for a junior

Recall that Terragrunt wraps Terraform to reduce repeated configuration and to run many small roots in order, and that plain root modules are a valid alternative.

for a middle

Explain which repetition include and root.hcl remove, what dependency and run --all add, and what extra concepts a team must now learn.

for a senior

Name the concrete failure modes the wrapper introduces, such as mocks in saved plans and a shared root file's blast radius, and how you would contain them in CI.

for a principal

Decide using the number of similar roots, how much ordering crosses them and who owns the layer. Separate state, which stays portable, from orchestration, which does not, and agree the exit plan before the pilot starts.

## The decision Terragrunt is a wrapper around Terraform or OpenTofu. Adopting it does not change what Terraform can create. It changes how many small root modules you can keep consistent and run in order, at the price of a second tool every engineer must learn. There is no universally right answer, and the useful interview answer names the signals that would change your mind. ## What the wrapper buys - **One definition of repeated settings.** A shared `root.hcl` holds the backend and provider, so forty copies become one, with a per-unit state key from `path_relative_to_include()`. - **Units that are a URL plus inputs.** A `terragrunt.hcl` pins a module with `?ref=`, so promoting a version across environments is a small diff. - **Run ordering across states.** `dependency` blocks pass outputs and build a graph that `run --all` follows in order, on apply and in reverse on destroy. - **Patterns as code.** `terragrunt.stack.hcl` can generate whole sets of units from a versioned catalog. ## What it costs - **Another layer to learn and debug.** Terraform runs in a folder under `.terragrunt-cache`, inputs arrive as `TF_VAR_` variables, and values come from merged parent files. Reading a plain root is simpler than tracing what a unit resolved to. - **A shared file with a wide blast radius.** A `root.hcl` edit reaches every including unit with no unit diff, so CI needs to find affected units, for example with `--queue-include-units-reading` or `--filter-affected`. - **New failure modes.** `mock_outputs` can leak into a saved plan, and `run --all apply` adds `-auto-approve`. Neither exists in plain Terraform. - **A support matrix.** Terragrunt lists officially tested Terraform and OpenTofu lines. At v1.2.1 that table's newest Terraform line is 1.14.x while Terraform is at 1.17, though the docs say compatibility is more relaxed in practice. They also say that support for Terraform-specific features of BSL-licensed releases is not guaranteed, and its default binary is `tofu`. A shop relying on new Terraform-only features should test this, not assume it. - **Upgrade churn, now lower.** The move to `run --all`, `TG_` variables and flags without the `terragrunt-` prefix forced script edits before 1.0. Terragrunt's 1.0 guarantees say commands, flags and HCL valid in 1.0 stay for all of 1.x. ## Where the lock-in sits | Asset | How tied to Terragrunt | Cost of leaving | |---|---|---| | Terraform modules | Not tied | None: they are ordinary modules | | State | Not tied; `remote_state` fills in a normal backend | Low: keep the same bucket and key | | Backend and provider blocks | Generated | Low: write them into each root | | `inputs` | Terragrunt syntax | Medium: convert to `.tfvars` or literals | | `dependency` outputs | Terragrunt only | High: needs another handoff | | Run order | Terragrunt only | High: CI or a run service has to own it | | Generated stacks | Terragrunt only | High: materialise units first | So lock-in is mostly about orchestration and configuration, not your data. This is a much milder form of lock-in than one that holds your state. ## Signals for the decision 1. **Count and similarity of roots.** Five distinct roots rarely repay a wrapper; dozens of near-identical ones across environments and regions might. 2. **Real dependencies between them.** If outputs and ordering cross many roots, orchestration is the main benefit. If they are nearly independent, thin roots plus CI can be enough. 3. **What already runs your plans.** If a run service or existing pipeline must call Terraform directly, check how a wrapper fits before you commit. 4. **Who maintains it.** A platform team can own a catalog; a team of five infrastructure part-timers may be better off with repetition it can read. 5. **Terraform-only features on your roadmap.** Check them against the support table first. ## Adopting without betting everything Convert one environment as a pilot, keeping state keys unchanged, and measure what changed: lines removed, review time, failed runs. Pin `terragrunt_version_constraint` and `terraform_version_constraint` so upgrades are deliberate, and set `--tf-path` or `terraform_binary` explicitly if you want Terraform and not `tofu`. Write down the exit in advance: real backend and provider blocks in each root, `terragrunt render` to see what a unit resolves to, a data handoff to replace `dependency`, and CI that owns the order. If you cannot describe that exit, the pilot is not finished.

  • What would make you say no to Terragrunt for those forty roots?
    If they turn out to be largely independent, the main benefit left is deduplicating a few blocks, which thin roots and a partial backend config can mostly do. I would also hesitate if the roadmap depends on new Terraform-only features or if nobody can own the layer.
  • If you later remove Terragrunt, what work is actually involved?
    Write real backend and provider blocks into each root, keeping each unit's existing bucket and key so no state moves. Convert `inputs` to `.tfvars` or literals, replace each `dependency` with a handoff such as a remote-state read, and have CI own run order. The ordering work is the largest part.
  • How do you stop the wrapper's upgrades from surprising the team?
    Pin `terragrunt_version_constraint` and `terraform_version_constraint` in the root config so a mismatched binary fails early, and set `--tf-path` or `terraform_binary` if you mean Terraform rather than the default `tofu`. Terragrunt's 1.0 guarantees cover commands, flags and HCL through 1.x, which lowers the risk considerably.

  • Adopting Terragrunt locks your state into a format only Terragrunt can read.
  • Terragrunt can create resources that Terraform itself cannot.
  • A repository of plain root modules is always wrong once it has more than a few roots.
  • Leaving Terragrunt means rewriting every Terraform module the units call.
  • Terragrunt's default binary is terraform, so a Terraform team needs no extra pinning.