Terragrunt execution boundaries
Separate wrapper execution from engine execution
Terragrunt evaluates its own configuration before invoking the selected infrastructure engine. That evaluation can involve more than reading static text. The executable pair, working directory, environment, source revision, generated files and dependency targets together determine what will run. Record their approved versions and paths. In this lesson no Terragrunt, Terraform or OpenTofu commands are executed.
Generated files and path assumptions
A generate block can materialize engine configuration in the working directory. Use a known path and inspect collisions with existing files.
# Static example only: local backend, not part of the fixture.generate "backend" { path = "backend.tf" if_exists = "overwrite_terragrunt" contents = <<-EOT terraform { backend "local" { path = "synthetic.tfstate" } } EOT}The example targets a synthetic local state filename relative to the engine working directory; this is intentionally separate from the module fixture. A generated backend file is not a migration plan. Terragrunt may execute the engine in a copied source tree; use path functions deliberately and inspect their resolution. Do not assume the current shell directory and engine directory are the same. See https://docs.terragrunt.com/reference/hcl/functions/ and https://docs.terragrunt.com/reference/hcl/blocks/.
Treat configuration as potentially executable
A run_cmd expression can launch an external program during evaluation, and hooks can launch programs around engine commands. Review included HCL, source modules, hooks and transitive scripts before parsing or planning. Do not use unreviewed hooks or automatically bootstrap backends.
Static review checklist- inspect every run_cmd and hook- reject unknown executables and arguments- examine credential and network boundaries- review backend initialization and generated file paths- record exact approved tool versionsA command named plan or validate does not make arbitrary wrapper configuration safe. Redacting command output is not equivalent to keeping secrets out of process arguments, files or state. See https://docs.terragrunt.com/features/units/hooks/.
Caches and dependency locks are different
A source cache stores working copies so Terragrunt can invoke the engine without treating the original source folder as its execution directory. It is not a version-control system, state backup or proof of artifact trust. The dependency lockfile records provider selections and integrity information. Review the lockfile associated with the unit and the wrapper’s documented copying behavior; do not casually edit checksums or remove state that happens to be in a cache. Provider downloads and parallel cache access need separate controls. See https://docs.terragrunt.com/features/units/terragrunt-cache/ and https://docs.terragrunt.com/features/units/lock-files/.
Choose the smallest command scope
Modern documentation describes run and run --all; older material may use run-all. Verify the approved executable help before choosing syntax. These commands are illustrations only.
terragrunt --versionterragrunt run -- plan# Broader scope, illustration only; do not execute here:terragrunt run --all -- planA multi-unit command can discover dependencies outside the starting directory. Review the resolved queue, not merely the folder where you start. The documented multi-unit apply and destroy behavior can bypass individual interactive approvals by adding auto-approval. Use separately approved per-unit plans rather than a recursive apply. Do not assume filtering is a security boundary or that independent units form one transaction. See https://docs.terragrunt.com/reference/cli/commands/run/.
Review an offline run request
Consider a fictional request to plan the dev app. Its dependency is the dev network. The test network must not enter the queue; a mock must not substitute for the real output during plan in our fixture.
Requested: dev/appAllowed dependency: dev/networkUnexpected target: test/network -> HOLDMissing real output for plan -> HOLDUnknown hook -> HOLDAll review gates satisfied -> ELIGIBLE_FOR_REVIEWUse the included Python decision model to test missing evidence. It is intentionally not an emulator: it cannot parse HCL, discover real dependencies, validate native mocks or prove any run is safe. For a real authorized lab, inspect the pinned engine and wrapper, actual queue, identities and state before generating a fresh plan. Next: Terragrunt stacks and dependency ordering.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Terragrunt execution boundaries — knowledge check
Review unit configuration, dependencies and execution boundaries.
Why review run_cmd before planning?
What is the role of a provider lockfile?
What should happen if a recursive queue contains an unexpected unit?
Does the source cache prove a configuration is trusted?
Why use separately approved per-unit plans?