In Terragrunt, what does `run --all apply` do across the units under your working directory, and what makes it riskier than applying one unit?
answer
- a graph, not a list
- reversed on destroy
- nobody is asked to approve
- where you stand sets the scope
- the old spelling has gone
basics
~20 sTerragrunt's run --all apply builds a dependency graph of the units under the current directory and applies them in order, in parallel where it can. It adds -auto-approve silently, so the working directory is the blast radius.
solid answer
~40 s`terragrunt run --all apply` discovers every unit under the working directory, builds a graph from their `dependency` and `dependencies` blocks, and applies dependencies before dependents, concurrently where the graph allows; `destroy` reverses the order. It is riskier because it silently adds `-auto-approve`, each unit plans separately so there is no single plan to review, and a failure stops only that unit's dependents, leaving earlier units applied. You limit it by running from a narrower directory, using `--filter`, and capping units with `--parallelism`, which has no limit by default. It replaced the older `run-all` command, whose name no longer exists in the 1.2 CLI.
code
bash · 8 lines# Scope by directory: only this region's units are queued
cd live/prod/us-east-1
terragrunt run --all --out-dir /tmp/tfplan -- plan
terragrunt run --all --out-dir /tmp/tfplan --parallelism 4 -- apply
# Scope by expression from the top of the repository
cd ../../..
terragrunt run --all --filter './live/stage/**' -- plango deeper
Recall that run --all runs a command on every unit below the current directory, in dependency order, and that it replaced the run-all command.
Predict the order for a small graph on apply and on destroy, and explain what happens to dependents when a unit fails. Know that -auto-approve is added for you.
Describe keeping the blast radius small in practice: a narrow working directory, filters, saved plans per unit and a parallelism cap. Say why the two queue-ignore flags are dangerous on state-changing commands.
Decide whether a whole-tree apply should exist in your process at all. Many separate states have no shared transaction, so weigh a one-command convenience against reviewing and rolling out one environment at a time.
## What the command does Terragrunt splits an estate into **units**, directories with a `terragrunt.hcl` that each hold their own state. `terragrunt run --all apply` runs `apply` in every unit it discovers under the current working directory. It is how Terragrunt runs many separate Terraform states as one operation, which plain Terraform does not do for you. Terragrunt calls this queue the **run queue**: 1. **Discovery.** It finds the units under the working directory. 2. **Graph.** It builds a directed acyclic graph from each unit's `dependency` and `dependencies` blocks. 3. **Ordering.** For `plan` and `apply`, dependencies run before the units that depend on them. For `destroy`, the order reverses. 4. **Execution.** Units run concurrently, but a unit waits until everything it depends on has completed successfully. Take `backend-app`, which depends on `mysql` and `valkey`, which both depend on `vpc`. `apply` runs `vpc`, then `mysql` and `valkey` in parallel, then `backend-app`. `destroy` runs `backend-app` first and `vpc` last. A `dependency` block adds an edge to the graph and exposes the target's outputs. A `dependencies` block adds edges only, for ordering without reading any outputs. ## Why it is riskier than applying one unit - **`-auto-approve` is added silently.** Units share one stdin, so individual prompts cannot work. `run --all` adds the flag to `apply` and `destroy`. `--no-auto-approve` removes it, but then you need another way to approve. - **The working directory is the blast radius.** Terragrunt's docs say that, for the most part, the current directory decides it: run from `live/` and you may touch every environment. - **There is no single plan to read.** Each unit plans and applies on its own, and a dependent's real inputs can change once its dependency has been applied. - **Failure leaves a partial result.** If a unit fails, Terragrunt does not attempt its dependents. Units already applied stay applied, because there is no shared transaction to roll back across separate states, and unrelated branches of the graph can still run. - **Concurrency is unlimited by default.** Every unit that is free to run starts at once, which can reach a provider's rate limit. ## Keeping it under control | Control | What it does | Caution | |---|---|---| | `cd live/prod/us-east-1` | Limits the queue to that subtree | The primary tool, per the docs | | `--filter './prod/**'` | Selects units by expression | A positive filter excludes everything else | | `--filter-affected` | Selects units changed against the default branch | Shorthand for a Git filter | | `--parallelism 4` | Caps how many units run at once | Separate from Terraform's own `-parallelism` | | `--out-dir /tmp/tfplan` | Saves one plan per unit, and `apply` uses them | Apply needs a plan for every unit | | `--fail-fast` | Stops remaining units on the first failure | Useful for a strict pipeline | | `--queue-ignore-errors` | Carries on past failures | Dangerous on `apply` or `destroy` | | `--queue-ignore-dag-order` | Ignores dependency order | Dangerous on `apply` or `destroy` | Units outside the working directory that the queue's units depend on are called **external dependencies**, and the current docs exclude them by default. Pull them in with `--queue-include-external` or `--filter '{./**}...'`. ## Previewing the queue You can see what a run would do before starting it: - **`terragrunt list --as destroy -l`** prints units in the order `run --all destroy` would process them, and `--as plan` does the same for a plan. - **`terragrunt dag graph`** prints the dependency graph in DOT format for rendering. - **`terragrunt run --graph apply`** is the narrower sibling of `--all`: it runs on the units in the graph of the current unit, not on everything below the directory. ## The renamed CLI Commands that worked a few years ago now mislead. The CLI redesign renamed a good deal: | Old form | Current form | |---|---| | `terragrunt run-all plan` | `terragrunt run --all plan` | | `--terragrunt-non-interactive` | `--non-interactive` | | `--terragrunt-parallelism` | `--parallelism` | | `--terragrunt-ignore-dependency-errors` | `--queue-ignore-errors` | | `TERRAGRUNT_NON_INTERACTIVE` | `TG_NON_INTERACTIVE` | In Terragrunt 1.2.1 `run-all` is no longer in the command table, and an unrecognised command stops with an error instead of being forwarded to Terraform. `terragrunt plan` still works as a shortcut for a single unit.
- How do you run a saved-plan flow across many units?`terragrunt run --all --out-dir /tmp/tfplan -- plan` stores one plan per unit in a tree that mirrors the stack, and the same flag on `-- apply` uses them. A plan must exist for every unit, and a plan scoped with `--filter` needs the same filter at apply. Plans made with mock outputs hold those mock values.
- `--queue-ignore-errors` keeps a run going past failures. When is that reasonable?On read-only commands such as `plan` or `validate`, where you want every error at once. On `apply` or `destroy` the docs warn it can lead to inconsistent state, because a dependent then runs against a dependency that did not succeed. `--queue-ignore-dag-order` carries a similar warning for state-changing commands.
- How does `-detailed-exitcode` behave under `run --all plan`?Terragrunt returns one aggregate code, not any single unit's. If any unit returns 1 the result is 1; otherwise if any returns 2 the result is 2; if none is non-zero it is 0. A script can detect that something would change, then read the per-unit output to see where.
- run --all apply stops and asks you to approve each unit's plan by default.
- Terragrunt rolls back units it already applied when a later unit fails.
- run --all destroy uses the same order as run --all apply.
- Terragrunt limits run --all to a small number of concurrent units by default.
- A dependencies block exposes the outputs of the units it lists.
- Terragrunt 1.2 still ships run-all as a current command.