{
  "slug": "terragrunt-block-iteration-expands-dependency-unit-and-stack-blocks-90536fca80f9",
  "title": "terragrunt block-iteration expands dependency, unit, and stack blocks",
  "tools": [
    "terragrunt"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-09-14T21:06:29.000Z",
  "announced_at": "2026-09-14T21:06:29.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When a stack configuration needs multiple units from one block, enable the `block-iteration` experiment and add an `expansion` block with `for_each` or `count`; give each unit a distinct path and address generated elements by key or index.",
    "examples": [
      "unit \"aurora\" {\n  expansion {\n    for_each = toset([\"web\", \"api\"])\n  }\n  source = \"../units/app\"\n  path   = \"aurora/${each.key}\"\n  values = { role = each.key }\n}"
    ],
    "gotchas": [
      "Version: v1.1.5",
      "Availability: The `expansion` blocks and `enabled` attributes on `unit` and `stack` require the `block-iteration` experiment.",
      "expansion.for_each: Set, map, or object to iterate; each instance exposes `each.key` and `each.value`. Set exactly one of `for_each` and `count`.",
      "expansion.count: Non-negative whole number of instances; each instance exposes zero-based `count.index`. Set exactly one of `count` and `for_each`.",
      "unit.path (required): Relative generated path; each expanded unit must have a distinct path.",
      "unit.enabled: Defaults to true; false skips the unit during stack generation and omits it from `terragrunt stack output`.",
      "Prerequisite: Enable the `block-iteration` experiment with `--experiment block-iteration` or `TG_EXPERIMENT=block-iteration`; `expansion` and `unit.enabled` are gated by the experiment.",
      "Adding an expansion changes the block's address; references and `stack output` scripts need updating by hand.",
      "Shrinking a `for_each` or lowering a `count` removes addresses; Terragrunt has no `moved` equivalent, so leftover state at a removed address has to be destroyed deliberately."
    ]
  },
  "why_it_matters": "Generate multiple Terragrunt dependencies, units, or stacks from one block in a stack configuration.",
  "sources": [
    "https://github.com/gruntwork-io/terragrunt/releases/tag/v1.1.5",
    "https://docs.terragrunt.com/reference/hcl/blocks/"
  ],
  "rank": 0.94037,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v2+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "wave2a-20261017",
    "verdict_id": "wave2a-20261017:wave2a-20261017-5d39902433a97c96-5:gate",
    "evidence_hash": "a0b224494781009d5bade0a0f232cffc6784e38957cb3d84b2c4e6eacf6ffd74"
  },
  "review": {
    "draft_hash": "ac9e72f36b6ba31608f22c5382b7cd70bad9575b315b700f4235ff3a9db96f42",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "wave2a-20261017:gate",
    "reason": "2 of 3 judge runs approved with p_yes >= 0.9 (mean 0.94 >= 0.9; 2 needed) and Jev gave 0.67 (>= 0.6 needed)."
  }
}
