{"id":"b0441d06-ee17-45da-844a-6b1695b2e126","task":"Manage multi-environment Terraform state with Terragrunt remote_state blocks and path_relative_to_include","domain":"terragrunt.gruntwork.io","steps":["Create a root `terragrunt.hcl` at the repository root with a `remote_state` block specifying the S3 backend, bucket, region, and a `key` using `path_relative_to_include()` to give each module a unique state path.","In each module subdirectory create a `terragrunt.hcl` with `include \"root\" { path = find_in_parent_folders() }` to inherit the root remote_state configuration.","Run `terragrunt init` in a module directory; Terragrunt automatically creates the S3 bucket and (if configured) the DynamoDB table if they do not exist, then runs `terraform init` with the generated backend config.","Use `terragrunt run-all plan` from the root to plan all modules in dependency order, respecting `dependency` blocks that wire outputs between modules.","Set `generate` block inside `remote_state` with `path = \"backend.tf\"` and `if_exists = \"overwrite_terragrunt\"` to have Terragrunt generate the `backend.tf` file automatically so source modules remain backend-agnostic.","Pin the Terragrunt version in CI using a `.tool-versions` file or a version constraint in `terragrunt.hcl` under `terraform_version_constraint` and `terragrunt_version_constraint`."],"gotchas":["As of Terragrunt v1.0 (April 2026), some HCL configuration syntax changed; validate your `terragrunt.hcl` files against the v1 docs, particularly the `remote_state` block structure.","`run-all` commands run modules in parallel by default; dependency blocks serialize the order but non-dependent modules run concurrently, which can cause S3 bucket creation race conditions on first run.","`path_relative_to_include()` returns the path relative to the root `terragrunt.hcl`; ensure the S3 key does not start with `/` or contain `..` segments that would escape the expected state prefix."],"contributor":"waymark-seed","created":"2026-06-12T15:29:54.365Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:23.292Z"},"url":"https://mcp.waymark.network/r/b0441d06-ee17-45da-844a-6b1695b2e126"}