sincecutoff.com
← all changes

terragrunt bounded-discovery constrains filter graph traversal

Introduced 2026-08-13 · score 0.98

HOW TO USE IT

When dependency-filter traversal in an isolated monorepo could reach sibling environments, enable `bounded-discovery` and constrain the graph search to the intended environment. Use `--discovery-boundary` for the command or an inline `(dir)` operand for one filter expression; the directory must exist.

cd <environment-dir> terragrunt run --all plan --experiment bounded-discovery --filter '...{<unit>}' --discovery-boundary .
cd <environment-dir> terragrunt run --all plan --experiment bounded-discovery --filter '(.)...{<unit>}'
terragrunt find --experiment bounded-discovery --filter '{<unit-path>}...' --discovery-boundary <boundary-dir>

WHY THIS HELPS

When traversing dependency filters in a monorepo with isolated environments, bound discovery to the intended environment so sibling configurations are not read or run.

BEFORE THIS CHANGE

Without bounded discovery, dependent filters searched up to the Git repository root and dependency filters followed declared paths; Terragrunt read and parsed configurations it touched.

REQUIREMENTS AND LIMITATIONS

  • Version: v1.1.3
  • Availability: Experiment
  • --experiment bounded-discovery (required): Enables the bounded-discovery experiment in v1.1.3.
  • --filter (required): Filter expression for the units to traverse; `...{unit}` selects dependents and `{unit}...` selects dependencies.
  • --discovery-boundary: Sets the directory boundary for traversal across filter expressions in the command. It must be an existing directory; relative paths resolve against the working directory. Dependent traversal requires the boundary to be the working directory or one of its parents; dependency-only traversal permits any directory, including one below the working directory.
  • TG_DISCOVERY_BOUNDARY: Environment-variable alternative to `--discovery-boundary` for setting the run’s directory boundary.
  • (dir) inline boundary operand: Bounds one filter expression and overrides the command boundary for that expression; the directory must exist. Parentheses are reserved for this operand, so wrap literal names or paths containing parentheses in braces.
  • --all: Runs the command across discovered units.
  • Prerequisite: Use Terragrunt v1.1.3 or later with the `bounded-discovery` experiment enabled using `--experiment bounded-discovery`.
  • Prerequisite: The boundary must be an existing directory. Relative boundary paths resolve against the working directory.
  • Boundary must be an existing directory.
  • Relative boundary paths resolve against the working directory.
  • Dependent traversal searches upward from the working directory; filters using it require the boundary to be the working directory or one of its parents.
  • Dependency traversal follows declared paths from matched units; dependency-only filters accept any directory, including one below the working directory.
  • Any configuration resolving outside the boundary, whether dependent or dependency, is not read, parsed, or returned; `find` does not list it and `run --all` does not run it.
  • Reserving `(` and `)` for the boundary operand changes how `--filter` reads those characters even when the experiment is disabled; an expression such as `1...(foo | bar)` is now rejected as a malformed boundary. Wrap names or paths containing parentheses in braces to keep them literal.
  • Docs conflict: Current official experiment documentation describes behavior after the experiment completed: the experiment flag is no longer needed. It also says the boundary limits discovery traversal rather than filtering results, and that dependencies outside the boundary can still be read and parsed. These statements differ from the v1.1.3 release note; use the release-note behavior for v1.1.3. https://docs.terragrunt.com/reference/experiments/active/

FIRST-PARTY EVIDENCE

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

Report a problem with this card