sincecutoff.com
← all changes

terragrunt stack-dependencies supports cross-stack dependency patterns

Introduced 2026-04-21 · score 0.96

HOW TO USE IT

When a stack needs dependencies on another stack or a unit in a nested stack, declare them in `autoinclude` in `terragrunt.stack.hcl` using stack paths and dependency outputs. Plan all units with the `stack-dependencies` experiment enabled.

stack "infra" { source = "<stack-source>" path = "infra" } unit "app" { source = "<unit-source>" path = "app" autoinclude { dependency "infra" { config_path = stack.infra.path } inputs = { vpc_id = dependency.infra.outputs.vpc.vpc_id } } }
stack "networking" { source = "<stack-source>" path = "networking" } unit "app" { source = "<unit-source>" path = "app" autoinclude { dependency "vpc" { config_path = stack.networking.vpc.path } inputs = { vpc_id = dependency.vpc.outputs.vpc_id } } }
terragrunt run --all --experiment stack-dependencies -- plan

WHY THIS HELPS

Configure a Terragrunt stack so units can depend on another stack or on a unit in a nested stack.

BEFORE THIS CHANGE

Before stack dependencies, stacks passed dependency paths to units through `values`, and units declared `dependency` blocks using those values as `config_path`.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.0.2
  • Availability: The `stack-dependencies` experiment.
  • stack.<name>.path (required): Path reference for depending on the whole named stack.
  • stack.<name>.<unit_name>.path (required): Path reference for depending on a unit within a nested stack.
  • dependency.<name>.config_path (required): Path to the dependency configuration; examples set it to a stack path reference.
  • dependency.<name>.outputs.<unit_name>.<output_key>: Access an output from a unit through a dependency targeting a stack directory; use the dependent stack's name and the unit/output names.
  • --all: Run the specified OpenTofu/Terraform command against all units in the current stack.
  • --experiment stack-dependencies (required): Enables the stack-dependencies experiment for the command.
  • plan (required): OpenTofu/Terraform command passed to `terragrunt run`.
  • Prerequisite: Enable the `stack-dependencies` experiment for the run with `--experiment stack-dependencies`.
  • Prerequisite: The stack and unit declarations, including their `source` and `path`, belong in `terragrunt.stack.hcl`; `autoinclude` is nested in the unit or stack declaration.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card