Repository navigation
v1.2.0-rc1 #7020
Replies: 1 comment
|
First, this took me a significant amount of time, but it was fun ;), I tested v1.2.0-rc1 in a sandbox: Docker on an arm64 Mac, OpenTofu 1.13.1, S3 and GCS emulators, no cloud accounts. When something failed or looked off, I ran it again on v1.1.6 to see if it is a regression, and on v1.2.0-rc2 to see if it is already fixed. The main results on rc1 were each run at least twice from clean directories. Some cross-version comparisons and smaller checks, such as the experiment-flag warnings, were run once.
The fallback on a network error does not always happen. On GCS, any network failure of the direct read (connection refused, dropped packets, a server that accepts and never answers) makes Setup
1.
|
| Fixed item | rc1 | v1.1.6 + experiment |
|---|---|---|
expansion + autoinclude, including an autoinclude that never uses each |
One terragrunt.autoinclude.hcl per element; each.key, each.value and count.index resolved (map/blue gets key = "blue", value = "B", count/1 gets index = 1); the values reach stack output after apply |
There is no variable named "each", nothing generated |
unit.<name>["key"].path addressing |
unit.producer["web"].path becomes config_path = "../producer/web", and ["api"] selects api; bare unit.producer.path fails with This object does not have an attribute named "path" |
Can't tell, fails earlier on the each error |
dependency with its own expansion inside autoinclude |
Set written as a literal and config_path resolved per key (see below); count variant works too; after apply the consumer's output holds both producers' real values, and the next plan has no changes |
each error |
Same label with and without expansion |
Parse error: unit "duplicate" is declared both with and without an expansion, so unit.duplicate cannot refer to both; rename one of them. Same for stack; for unit I tried both declaration orders |
Accepted, generates both |
dependency on a stack directory with an expanded unit |
dag graph has an edge to every element. With producers sleeping 1 s and 4 s, the consumer started 30-35 ms after the slower one finished, in two runs; without the dependency it started at once |
No edges to the elements, and run --all fails on the each error. I did not see the "ran without waiting" failure itself |
dependency on a stack that has enabled = false units/stacks |
Generation logs Skipping disabled unit / Skipping disabled stack; no disabled path in the tree or in dag graph; run --all succeeds |
dag graph lists .../disabled-unit and run --all fails with does not contain a terragrunt.hcl file |
For the nested dependency case, this stack file
locals { keys = toset(["web", "api"]) }
unit "producer" {
expansion { for_each = local.keys }
# ...
}
unit "consumer" {
# ...
autoinclude {
dependency "producer" {
expansion { for_each = local.keys }
config_path = unit.producer[each.key].path
}
}
}generates this in .terragrunt-stack/consumer/terragrunt.autoinclude.hcl:
dependency "producer" {
expansion {
for_each = toset(["api", "web"])
}
config_path = {
api = "../producer/api"
web = "../producer/web"
}[each.key]
}The dependency example from the release notes, in a plain terragrunt.hcl with sibling units aurora-web and aurora-api, also works. dag graph shows "consumer" -> "aurora-api" and "consumer" -> "aurora-web", apply gives the consumer both outputs (ids = "id-web,id-api"), and the next plan -detailed-exitcode exits 0. I ran it twice each on rc1, rc2 and v1.1.6 with the experiment.
Other cases that worked:
for_eachover a set and over a map,count, and expanded nested stacks.enabledset fromvaluesand fromeach.- An empty
for_each, which generates no units. - Keys
a.b,a banda/b.a/bbecomes a nested directory, andstack outputkeeps the original key. - Two elements with the same
path, which are rejected withduplicate unit path found. --experiment block-iteration, which prints the "already completed" warning and generates normally.
I also tried it on a real stack file. I refactored terragrunt-infrastructure-live-stacks-example at 5da4c11e in two ways: once to one expanded unit driven by a map, and once to one expanded dependency in the service's autoinclude. Both refactors generated the same unit tree, the same find, list and dag graph output, and the same remote_state key as the original, so no state would move. The only differences were in the generated terragrunt.autoinclude.hcl files. That stack's three units differ in source, values and dependencies, though, so expansion saved about one block there.
Two things I noticed on the way, both on rc1 and rc2:
-
When the
for_eachof an expandeddependencyusesunit.<name>.pathvalues, the generated autoinclude contains absolute paths from the machine that ranstack generate, whileconfig_pathis correctly relative. With the stack in/some/checkout:dependency "dep" { expansion { for_each = { db = "/some/checkout/live/.terragrunt-stack/db" role = "/some/checkout/live/.terragrunt-stack/roles/role" } } config_path = { db = "../db" role = "../roles/role" }[each.key] }
So the generated file changes with the checkout location. Using
toset([...])for the keys and looking the path up in a local map avoids it. -
render --jsonin the consumer unit prints the expanded dependency'sconfig_pathas the raw expression ("${{ db = \"../db\" ... }[each.key]}") instead of the resolved paths.find --daganddag graphdo resolve it.
Addresses on a stack that was already applied, local backend:
- Adding
expansion { count = 1 }without changingpath: the state stays the same (same lineage and serial), and the plan shows no changes. Only the key instack outputchanges, fromitemtoitem["0"]. - Adding
expansionwith apaththat useseach.key(itembecomesitem/aanditem/b): each new element plans1 to addwith its own new state. The olditemunit and its state stay in.terragrunt-stackand still planNo changes, so the old resource is neither moved nor destroyed. This is what the Lifecycle section warns about. I ran it twice on rc1 and once each on rc2 and v1.1.6. - Shrinking
for_eachfrom{a, b}to{a}:stack generateleft.terragrunt-stack/app/bin place, andrun --allkept planning it, as the Lifecycle section and thestack generatedocs describe.stack generate --source-updateremoved it. v1.1.6 behaves the same.
2. Dependency outputs read from state
Backends: S3 on SeaweedFS (endpoints.s3 + force_path_style = true) and GCS on fake-gcs-server (STORAGE_EMULATOR_HOST). To see which path ran, I pointed TG_TF_PATH at a wrapper that logs every tofu call before running it. Commands:
terragrunt --log-level debug run --all -- plan -input=false
terragrunt --log-level debug run --all --no-dependency-fetch-output-from-state -- plan -input=false
TG_NO_DEPENDENCY_FETCH_OUTPUT_FROM_STATE=true terragrunt --log-level debug run --all -- plan -input=falseWith the default settings, Terragrunt reads the dependency from state. The debug log shows Retrieved dependency outputs for .../producer/terragrunt.hcl directly from s3 state (or gcs state), and the wrapper log has no init or output -json call in the producer directory. With the flag or the env var, the wrapper shows output -json for the dependency, plus init -get=false when the dependency's working directory is not initialised yet.
The outputs were the same in both modes. I compared the consumer's planned values from tofu show -json byte for byte. The producer had strings, unicode, a large integer (9007199254740993), a long decimal, bools, lists, maps, and a nested object with a null. It also had a sensitive output, for which I compared only the value, not the sensitivity marking. For one consumer in the 10 x 10 stack below, the plan JSON from the direct read and from the forced mode was identical.
A network failure of the direct read can hang instead of falling back
The notes say that when a direct read "fails on a permissions or network error, Terragrunt falls back to tofu/terraform output -json... only the speedup is lost". In my tests that held on S3 when the connection fails (refused: a few seconds, dropped packets: about 93 s), but not on GCS, and not on S3 when the server accepts the connection and never answers.
To test only the reader, I gave Terragrunt's process a dead endpoint (STORAGE_EMULATOR_HOST / AWS_ENDPOINT_URL_S3), and the TG_TF_PATH wrapper gave tofu the working one, so the fallback could succeed if Terragrunt started it. The dead endpoints were a closed port (refused), a container that drops all TCP packets (dropped), and a server that accepts the connection and never replies (silent). The timeout wrapper around Terragrunt stopped each run at 600 s:
| Direct read fails with | S3 | GCS |
|---|---|---|
| connection refused | falls back after 1.5-4.7 s (n=5) | no result after 600 s (n=3, one run to 1,500 s) |
| dropped packets | falls back after 93-94 s (3 attempts x 30 s dial timeout, n=3) | no result after 600 s (n=3) |
| accepted, then silent | no result after 600 s (n=3) | no result after 600 s (n=3) |
The four hanging cases behave the same on v1.1.6 with --experiment dependency-fetch-output-from-state and on rc2 (n=3 each). With --no-dependency-fetch-output-from-state the same four cases finish in 0.2 s with the correct outputs, so the hang is in the reader. disable_dependency_optimization = true on the producer did the same for the two silent cases; I did not run it on the other two. Every run that did finish gave the same values as the healthy baseline.
While it hangs, the last log line is a DEBUG one, so at the default log level the user sees nothing:
14:55:31.173 DEBUG [../producer] Fetching outputs directly from gs://tgstate/producer/default.tfstate
Only when timeout sends SIGTERM, 10 minutes later in this run, does the read give up and log the fallback:
15:05:31.115 DEBUG [../producer] Could not read dependency state for .../producer/terragrunt.hcl directly (opening dependency state at gs://tgstate/producer/default.tfstate: retry failed with context canceled; last error: Get "http://127.0.0.1:9999/tgstate/producer%2Fdefault.tfstate": dial tcp 127.0.0.1:9999: connect: connection refused). Falling back to native output retrieval.
The GCS client keeps retrying the dial and never returns an error. A server that stays silent never produces one at all. So there is nothing to trigger the fallback. At v1.2.0-rc1 the Azure reader already bounds its read with context.WithTimeout(ctx, defaultAzureReadTimeout) (5 minutes). I found no deadline in the S3 and GCS readers. I did not run the Azure reader.
For a CI job, this means a unit whose dependency's state is on GCS and unreachable, or on S3 behind a server that accepts and stays silent, now hangs until the job's own timeout, while before the default changed it would have run tofu output. AWS_MAX_ATTEMPTS=1 shortened the S3 refused and dropped cases (0.2 s and 30 s) but not the silent one. Nothing I tried bounded the GCS refused case: AWS_* variables don't apply there, and TG_NO_AUTO_RETRY=true still had no result after 300 s (one run each). A per-read deadline for S3 and GCS, like the Azure one but probably much shorter, would let the documented fallback run. Until then, --no-dependency-fetch-output-from-state is the workaround.
These are emulators (SeaweedFS and fake-gcs-server over plain HTTP), not real AWS or GCP. The retry and timeout behaviour comes from the AWS and Google SDK clients, so I expect the same against the real services, but I did not test that.
Other fallback cases:
- An HTTP 403 on the direct read falls back. On S3, a proxy rejected only Terragrunt's user agent; on GCS, a fake server returned 403. In both cases Terragrunt logs
Could not read dependency state ... Falling back to native output retrieval.at debug level, and the values are the same. - The local backend has no reader and uses
output -jsonas before. - For a producer with no state object yet (on GCS), the direct read gets
object doesn't exist, and Terragrunt usesmock_outputs, the same as the forced mode. - With OpenTofu state encryption, the reader detects the encrypted object (
dependency state is encrypted) and does not return ciphertext. Whether the fallback then works depends on where the encryption config lives. Withgenerate "encryption"in the producer and no initialised producer directory, the retry failed withThis state file is encrypted and can not be read without an encryption configurationon rc1, rc2 and v1.1.6, so this is not a regression. Settingdisable_dependency_optimization = truefixed it. I did not testremote_state.encryption. --dependency-fetch-output-from-statestill works and warns that it is deprecated. With--strict-control dependency-fetch-output-from-statebefore the subcommand, it fails withis no longer supported.--no-dependency-outputson aplanthat needs the outputs fails withNo value for required variable, as the notes warn.
use_path_style is ignored by the S3 reader
The OpenTofu S3 backend docs mark force_path_style as deprecated and say "Use use_path_style instead". Terragrunt's reader honours only force_path_style. With use_path_style = true against a path-style-only store, the reader puts the bucket name in the hostname and then falls back (log line wrapped and shortened):
DEBUG [../producer] Could not read dependency state for .../producer/terragrunt.hcl directly (fetching dependency
state from s3://tgstate/a-use/producer.tfstate: operation error S3: GetObject, https response error StatusCode: 0,
... Get "http://tgstate.seaweed:8333/a-use/producer.tfstate?x-id=GetObject": dial tcp: lookup
tgstate.seaweed on 127.0.0.11:53: no such host). Falling back to native output retrieval.
| Binary | force_path_style = true |
use_path_style = true |
|---|---|---|
| v1.2.0-rc1 | direct read | fallback (dependency init + output) |
| v1.2.0-rc2 | direct read | fallback |
| v1.1.6 + experiment | direct read | fallback |
I ran each case twice from a clean directory. This is not a regression. It is the part of #3472 that was never implemented: the maintainer's stated plan there was to support both keys, and the PR (#3473) was closed as stale. The outputs are correct either way, so for dependency reads this costs only the speedup. Terragrunt prints nothing about it at the default log level.
At v1.2.0-rc1, the only path-style key in the S3 config struct is force_path_style. Bootstrap may have the same gap. One --backend-bootstrap run with use_path_style = true failed at HeadBucket with the bucket name in the hostname, but I did not get a clean force_path_style control, so this is only a lead.
Suggestion, untested: map use_path_style to the same field.
Wall time
The stack had 10 producers, each with its own S3 state key, and 10 consumers that each depend on all 10 producers. I timed terragrunt run --all -- plan inside the container, in alternating pairs with the direct read first. The samples are small (2 to 10 runs per cell), so read these as indicative:
| Run | Producers | Direct read | --no-dependency-fetch-output-from-state |
|---|---|---|---|
| From the stack root (producers are in the run) | builtin provider | 0.41 s | 0.46 s |
| From the stack root | hashicorp/random, empty provider cache |
2.23 s | 2.13 s |
From consumers/ (producers are external dependencies) |
builtin provider | 0.25 s | 0.37 s |
From consumers/ |
hashicorp/random, lock files, warm plugin cache |
0.25 s | 0.40 s |
From consumers/ |
hashicorp/random, lock files, empty provider cache |
0.26 s | 1.7-2.0 s |
From consumers/ |
hashicorp/random, no .terraform.lock.hcl |
0.32 s | 6.65 s |
When the producers are in the same run --all, the old path reuses their initialised working directories and adds only 10 output -json calls, so the modes differ by about 0.05 s with the builtin provider and not at all with a real one. When the producers are outside the run (here, run --all started from a subdirectory), the old path runs init -get=false and output -json for each of the 10 dependencies, and the direct read skips all 20 calls. How much time that saves depends on the providers. Without a lock file, every dependency init installed the provider again, which took about 0.65 s each. I did not find out why that happens with a warm plugin cache.
3. CAS-linked generated files can be edited in place as root
This is outside the two features, but it is new in 1.2. The CAS page says that a linked file "cannot be edited in place: writing to a linked file fails with a permission error", because "permitting edits would corrupt the content other configurations depend on". As root, the write does not fail, for example in a CI container that runs as root.
Here, two units have the same generate block, and only unit a has a hook:
generate "probe" {
path = "generated.tf"
if_exists = "overwrite_terragrunt"
contents = "output \"probe\" { value = \"shared\" }\n"
}
# unit a only
terraform {
before_hook "edit" {
commands = ["plan"]
execute = ["sh", "-c", "echo '# edited by unit a' >> generated.tf"]
}
}I ran terragrunt run -- plan in a, then in b, as root, with the CAS store and the units on the same container filesystem:
unit a plan exit=0
unit b plan exit=0
--- unit b generated.tf (unit b has no hook):
# Generated by Terragrunt. Sig: nIlQXj57tbuaRZEa
output "probe" { value = "shared" }
# edited by unit a
--- CAS blob name : 9142b63ae60173c17da6c9c419a52115a8d6a0f543550ae68b1e0c672736b944
--- sha256 content: c6f8437a332afc5957fc7dac4f6d1def13b9a631b60481ef1abea5921d7776ce
The behaviour is the same on rc2. v1.1.6 stores no blob, and b keeps its own content. A new unit with the same block, created in a later run, also got the edited file until I cleared the CAS store. Nothing reports that the blob no longer matches its name. As a non-root user, the plain append fails as documented (Permission denied), but a hook that runs chmod u+w first gets the same result as root.
I'm not filing this as a bug, because the docs already say not to edit these files without mutable = true. But the "fails with a permission error" safeguard does not apply as root, so a hook that worked before 1.2 can silently change other units' files after the upgrade. Some options:
- Say in the docs that root bypasses the safeguard.
- Add a troubleshooting entry that points from a hook
Permission deniedon a generated file tomutable = true/--no-cas. - If it is cheap enough, compare the blob with the generated contents before reusing it.
Other changes I checked
base64gzip(): for the same input, the encoded string differs from v1.1.6, but the decoded bytes are identical.base64gzip_compat()with--experiment base64gzip-compatreturns the v1.1.6 string, and without the experiment it fails with a clear message.- Passing any of the eleven completed experiments with
--experiment <name>prints the "already completed" warning and continues. An unknown experiment name still fails. - These features worked without experiment flags: discovery boundaries (
--discovery-boundary ./stagingand the(./staging)...vpcfilter dropped the dependent outside the boundary),catalog --format=jsonl|md,--profile-dir, theversionattribute on atfr://source, and--no-dependency-outputsand--no-hookson simple units. - On a 24-unit dependency chain with the local backend,
find,list,dag graph,hcl fmt --check,hcl validate, andrun --allplan, apply and destroy behaved the same as on v1.1.6, and the applied value reached the last unit. I timed two sets of 5run --all -- planruns. The medians were 1.76 s on rc1 against 2.02 s on v1.1.6 in the first set, and 1.67 s against 1.70 s in the second. One rc1 run in the first set took 2.81 s, against a 2.32 s worst case on v1.1.6. The second set had no such run, and another container was busy on the same host during the first, so I think it is noise, but I did not prove it. Peak RSS was about 4% higher on rc1.
What I could not test
- I had no real AWS, GCP or Azure account, so there is no coverage of IAM, KMS, assume-role, Azure Storage, Azure bootstrap or the new
minimum_tls_versionsetting. The S3 and GCS results come from emulators. I'll do (in Azure) for the upcoming RC, since I have some uses cases at work that I can use to test this. - For S3 bootstrap and the
RootAccesschange, I only checked theskip_bucket_root_accessdeprecation warning.
Uh oh!
There was an error while loading. Please reload this page.
🎉 v1.2.0 Release Candidate
This is the first release candidate for Terragrunt v1.2.
This release completes the following experiments:
block-iterationocibounded-discoverycatalog-formatmutable-generateoptional-dependency-outputsoptional-hooksazure-backendversion-attributeprofilingdependency-fetch-output-from-stateFuture release candidates for v1.2.0 will include bug fixes related to these experiments or other urgent bug fixes as necessary, and documentation improvements.
Please try out this release candidate in lower environments and share your feedback in the Associated GitHub discussion.
🛠️ Breaking Changes
base64gzip()uses the Go 1.27 encoderGo 1.27 changed the compressed output of its gzip encoder. Terragrunt v1.1.5 kept
base64gzip()on the older output and warned once per run that this was legacy behavior.base64gzip()now returns what the Go 1.27 encoder produces.A resource that compares the encoded value can plan a replacement on the first run after upgrading. An
aws_instancewithuser_data_base64set frombase64gzip()anduser_data_replace_on_changeset totrueis one such resource.Where the encoded value has to stay stable, call the experimental
base64gzip_compat(), which returns the v1.1.3 output permanently. It is behind thebase64gzip-compatexperiment and may be renamed or removed:This completes the
legacy-base64gzipstrict control.Note
Within the 1.0 guarantees
The 1.0 guarantees make promises about how Terragrunt remains backwards compatible. This change does not break those promises. It is listed under breaking changes so you are aware of it, in case it affects your workflows.
base64gzip()still takes a string and returns valid gzipped base64 content that decompresses to the same value, but the encoded value itself changes.base64gzip_compat()keeps the old one.S3 state buckets no longer get the
RootAccessbucket policy statementWhen bootstrapping an S3 state bucket, Terragrunt attached a bucket policy statement with the
SidRootAccessthat granteds3:*on the bucket and its objects toarn:aws:iam::<account-id>:root, an ARN that grants access to the AWS account as a whole rather than only to its root user. That statement has been removed. It widened reach to state files that routinely hold secrets, and the account already owns the bucket.The
skip_bucket_root_accessconfig no longer has anything to skip, and is now deprecated. Terragrunt still accepts it, and warns about it when bootstrapping a backend whose config sets it. Enable theskip-bucket-root-accessstrict control to turn that warning into an error.To grant the AWS account root user access to the state bucket, set the new
enable_bucket_root_accessconfig:Buckets that already have the statement keep it. The state backend docs cover how to remove it yourself.
Note
Within the 1.0 guarantees
The 1.0 guarantees make promises about how Terragrunt remains backwards compatible. This change does not break those promises. It is listed under breaking changes so you are aware of it, in case it affects your workflows.
The bucket policy Terragrunt writes is not part of the CLI, HCL, or output schemas the guarantees pin, and
skip_bucket_root_accessremains valid configuration. Removing the statement is a bug fix, andenable_bucket_root_accessrestores it. See Bugs in the guarantees for how a bug fix in 1.x can change your workflows.✨ New Features
Non-interactive
terragrunt catalogoutput with--formatThe catalog TUI needs a terminal. The
--formatflag (env:TG_FORMAT) writes what the catalog discovers to standard output, so a script or an agent can read the catalog without one.--format=jsonlwrites one JSON object per catalog entry, following a published JSON schema:--format=mdwrites a Markdown document with a section per entry:terragrunt catalog --format=md > catalog.mdWithout
--format,terragrunt catalogopens the TUI only when standard input and standard output are both terminals. Anywhere else it writesjsonl, so piping the command needs no flag:Terragrunt writes each entry as it discovers it. See Non-interactive catalog for the structure of each format and how streaming behaves.
Previously gated behind the
catalog-formatexperiment, non-interactive catalog output no longer requires--experiment catalog-format.Collect runtime profiles
Terragrunt writes CPU, heap, and goroutine profiles on request, so you can see where a slow run spends its time. Pass
--profile-cpu,--profile-memor--profile-goroutinewith a path, or--profile-dirto collect all three into one directory under conventional names. Each flag has a matchingTG_PROFILE_*environment variable.Read the result with
go tool pprof. The profiles cover Terragrunt itself, not the OpenTofu/Terraform processes it runs.Previously gated behind the
profilingexperiment, the profile flags no longer require--experiment profiling.Bound discovery with
--discovery-boundaryand(dir)filtersGraph filters search up to the Git repository root for dependents and follow dependencies wherever they point, so in a monorepo they can parse sibling environments a command never needed.
A
(dir)operand in a graph filter stops traversal at that directory:From the same directory, the
--discovery-boundaryflag (env:TG_DISCOVERY_BOUNDARY) applies one boundary to every--filterexpression on the command:Previously gated behind the
bounded-discoveryexperiment, bounded discovery no longer requires--experiment bounded-discovery.Terragrunt docs MCP server
Terragrunt now publishes the read-only Terragrunt docs MCP server, which answers Terragrunt questions from the official docs, the CLI reference, a curated design-pattern library, and real example config. The server is public and unauthenticated. Results are pinned to a Terragrunt version, and docs pages can be read at any release tag from v0.80 onward.
For Claude Code:
Cursor and other MCP clients that read an
mcp.jsonpoint athttps://mcp.docs.terragrunt.com/mcpinstead.The server is in public beta. It has no availability guarantee and may change significantly.
See the install docs for the full setup.
Download modules from OCI registries
An
oci://source downloads a module from an OCI Distribution registry, such as Amazon ECR, GitHub Container Registry, Azure Container Registry, Google Artifact Registry, or a self-hosted one. It works in aterraformblock:And in the
unitandstackblocks of aterragrunt.stack.hcl:Pin the artifact with
tagordigest. Setting neither selects thelatesttag, and a//subdirselector reaches a directory inside the module, unit, or stack. Credentials come from OpenTofu's CLI config, from ambient Docker config, and from credential helpers such asecr-login, so one source string resolves the same way under bothtofuand Terragrunt.Previously gated behind the
ociexperiment, these sources no longer require--experiment oci. See OCI registries for the publishing contract and the full authentication order.Track the files that OpenTofu file functions read
Terragrunt records the files that the built-in file functions read, so reading-based filters select the units that read them without a
mark_as_readcall:filetemplatefilefilesetfileexistsfile*hash functions, such asfilesha256A file read from inside a template counts too.
mark_as_readremains the way to record a file that only OpenTofu/Terraform reads, such as one passed to a module as an input, or one arun_cmdscript reads.Generated files stored in the CAS
The Content Addressable Store (CAS) now stores the files that
generateblocks produce. Each unit's working directory gets a hard link to the stored copy, so every unit that includes this block shares oneprovider.tfon disk:Generated files are read-only by default, so an existing hook or script that edits a generated file in place fails with a permission error. Set
mutable = trueon thatgenerateblock to give each unit a writable file of its own:Passing
--no-casturns off the CAS for a run, and Terragrunt writes generated files as plain files:See Generate blocks and Immutable by default for details.
Previously gated behind the
mutable-generateexperiment, CAS storage for generated files no longer requires--experiment mutable-generate.Iterate
unit,stack, anddependencyblocks withexpansionAn
expansionblock declares acountor afor_each, and Terragrunt reads the block it sits in once per element. Thisunitblock generates two units, at.terragrunt-stack/aurora/weband.terragrunt-stack/aurora/api:A
stackblock expands the same way, generating one stack per element.An expanded
dependencyblock produces one dependency per element, andinputsreads each one by its key:unitandstackblocks also accept anenabledattribute. Setting it tofalseskips the component during stack generation:Adding an
expansionblock to an existing block, or shrinking one, changes the addresses of the components it produces. Read theexpansionreference before changing one that has already been applied.Previously gated behind the
block-iterationexperiment,expansionblocks and theenabledattribute no longer require--experiment block-iteration.Bootstrap, delete, and migrate Azure Storage state backends
Terragrunt provisions the resource group, storage account, and blob container backing an
azurermstate, and converges blob versioning and soft delete on both new and pre-existing accounts. It also deletes state blobs and containers, and migrates state within a storage account. Dependency outputs of Azure-backed units are read straight from the state blob, the same as S3 and GCS.If you already pass
--backend-bootstrap, Terragrunt now creates Azure resources it skipped before.Previously gated behind the
azure-backendexperiment, these operations no longer require--experiment azure-backend. See State Backend for configuration keys and authentication.Set the minimum TLS version on a bootstrapped Azure storage account
The ARM API treats an unset minimum TLS version as
TLS1_0, but Azure deprecatedTLS1_0andTLS1_1in August 2025.Terragrunt now provisions a new storage account with a minimum TLS version of
TLS1_2. Theminimum_tls_versionoption raises it toTLS1_3:TLS1_2andTLS1_3are the only accepted values. Terragrunt rejects the deprecatedTLS1_0andTLS1_1.The setting applies only when Terragrunt creates the account. Terragrunt leaves an existing account's setting alone, so change it there with the Azure portal or CLI.
Call OpenTofu 1.13 built-in functions in Terragrunt configurations
Terragrunt evaluates the built-in functions in configurations using its own copy of the OpenTofu implementations, which tracks OpenTofu 1.13.
These functions are now available:
assumeequalassumelistlengthassumelistlengthmaxassumelistlengthminassumemaplengthassumemaplengthmaxassumemaplengthminassumenotnullassumesetlengthassumesetlengthmaxassumesetlengthminassumestringprefixbase64gunzipcidrcontainsephemeralasnullissensitivetemplatestringurldecodeRead dependency outputs from state by default
Terragrunt reads dependency outputs straight from the remote state object, without initializing each dependency to run
tofu outputorterraform outputagainst it. This covers the S3, GCS, and Azure Storage (azurerm) backends.When a direct read is unsupported, such as for a backend Terragrunt has no reader for, or fails on a permissions or network error, Terragrunt falls back to
tofu/terraform output -json. The outputs are the same either way, so only the speedup is lost.Pass
--no-dependency-fetch-output-from-state(env:TG_NO_DEPENDENCY_FETCH_OUTPUT_FROM_STATE) to always load dependency outputs throughtofu/terraform output -json.Previously gated behind the
dependency-fetch-output-from-stateexperiment, direct state reads no longer require--experiment dependency-fetch-output-from-state. Passing--dependency-fetch-output-from-statestill works, and thedependency-fetch-output-from-statestrict control turns its deprecation warning into an error.Version constraints for registry modules
The
terraformblock accepts aversionattribute holding a version constraint for atfr://registry module. Terragrunt downloads the highest published version that satisfies the constraint, using the same syntax as theversionargument on OpenTofu and Terraformmoduleblocks:See the
terraformblock reference for the full rules.Previously gated behind the
version-attributeexperiment, version constraints for registry modules no longer require--experiment version-attribute.S3 buckets can be created in your account regional namespace
An account regional namespace is a reserved subdivision of the S3 bucket namespace that only your account can create buckets in, so no one else can take or re-create those names. Bucket names in it end with your account ID, the region, and
-an.When a bucket name matches that convention, Terragrunt creates the bucket in the account regional namespace:
There is no setting to enable this. S3 accepts the
-ansuffix only for account regional buckets, so the name alone decides.accesslogging_bucket_nameis read the same way. Buckets named any other way are created in the global namespace, and the namespace is left out of the request entirely, so S3-compatible object stores are unaffected.A name that fits the convention but names a region other than the bucket's own fails immediately.
Skip dependency outputs with
--no-dependency-outputsThe
--no-dependency-outputsflag (env:TG_NO_DEPENDENCY_OUTPUTS) skips output resolution for everydependencyblock in a run, so Terragrunt does not calltofu outputon dependencies that may not be applied yet:Warning
Use this flag with commands that do not read dependency outputs, such as
initandvalidate. While it is set, references to dependency outputs get no real value, soplanandapplycan pass empty values to OpenTofu/Terraform in their place.Previously gated behind the
optional-dependency-outputsexperiment, the flag no longer requires--experiment optional-dependency-outputs.Skip hooks for a run with
--no-hooksThe
--no-hooksflag (env:TG_NO_HOOKS) skips every hook for a run:before_hook,after_hook, anderror_hookblocks.Previously gated behind the
optional-hooksexperiment,--no-hooksno longer requires--experiment optional-hooks.🐛 Bug Fixes
S3 access log delivery is granted with a bucket policy
S3 disables ACLs on new buckets by default, and a bucket with ACLs disabled rejects the ACL grant Terragrunt wrote to make an access logging bucket accept logs. AWS recommends a bucket policy over an ACL for this grant, and recommends keeping ACLs disabled in general.
Terragrunt now creates buckets with ACLs disabled and grants access log delivery through the logging bucket's policy instead, allowing
s3:PutObjectfor thelogging.s3.amazonaws.comservice principal on behalf of buckets in the same AWS account:This only applies to a logging bucket Terragrunt creates. One that already exists keeps the permissions it has, whether that is the ACL grant from an earlier Terragrunt version or something you set up yourself, and Terragrunt neither reads nor writes its policy.
skip_accesslogging_bucket_policyopts out of that grant.skip_accesslogging_bucket_aclis deprecated and now has no effect: Terragrunt puts no ACL on the logging bucket, so there is nothing left for it to skip.If you set
skip_accesslogging_bucket_aclto work around anAccessControlListNotSupportedfailure on a bucket with ACLs disabled, drop it. The bucket policy covers that bucket, and the attribute now suppresses nothing. Setskip_accesslogging_bucket_policyonly if you grant log delivery yourself. Terragrunt warns when the deprecated attribute is used, and theskip-accesslogging-bucket-aclstrict control turns that warning into an error.expansionworks withautoincludeand stack dependenciesterragrunt stack generatefailed withThere is no variable named "each"when aunitorstackblock declared both anexpansionblock and anautoincludeblock. The error pointed ateach.keyinpath, even whenautoincludenever referencedeach.Generation now writes an autoinclude file for each element, and
each.key,each.value, andcount.indexinsideautoincluderesolve to that element:The
prodelement gets thisterragrunt.autoinclude.hcl:A
dependencyblock insideautoincludethat declared its ownexpansionblock failed generation with the same error. A unit whoseterragrunt.autoinclude.hclcontained one also failed to parse. An expanded unit could not be referenced from the stack file at all, sinceunit.<name>.pathskipped it.Each element of an expanded unit or stack is now referenced as
unit.<name>[key].path. The generateddependencyblock keeps itsexpansionblock. Generation evaluatesfor_eachorcountin the stack file, wherelocal.*andvalues.*are available, writes the result as a literal, and resolvesconfig_pathfor each element. The generated unit expands the dependency when it is parsed:A stack file that declares the same
unitorstacklabel both with and without anexpansionnow fails to parse, becauseunit.<name>cannot refer to both.Discovery failed the same way on a
dependencywhoseconfig_pathpointed at a stack directory containing an expanded unit. It dropped the dependency instead of reporting the error, sorun --alldid not wait for the units in that stack. The dependency now covers every element of the expanded unit.Malformed
{}groups in glob patterns no longer crash TerragruntSome glob patterns with an empty or unclosed
{}group crashed Terragrunt when it matched them, e.g.terragrunt find --filter '{./a{}'. Others silently failed to match, so{}adid not matcha.Terragrunt now refuses these patterns with an invalid pattern error. This covers filter queries,
include_in_copyandexclude_from_copyin theterraformblock, and.terragrunt-catalog-ignorefiles. A group with one empty option next to a non-empty one, such asmain.tf{,.bak}, still works.hcl validate --inputsreads-varand-var-filearguments verbatimhcl validate --inputsapplied shell quoting rules to each entry inextra_argumentsbefore reading-varand-var-filefrom it. Those rules treat a backslash as an escape character, so on Windows a var file path such as"-var-file=${get_terragrunt_dir()}\\varfiles\\main.tfvars"lost its separators, and validation failed to open the file.Terragrunt now reads each entry in
argumentsexactly as written, as the single argument it becomes on the OpenTofu/Terraform command line.Units with identical configs each resolve their own
iam_roleWhen two units had the same
terragrunt.hclcontent, Terragrunt could assume the first unit's IAM role for both. This hit anyiam_rolethat depends on the unit's directory, such as:With this config in
a/andb/,bassumedrole/ainstead ofrole/b. Terragrunt now evaluatesiam_rolein each unit's own directory, soget_terragrunt_dir(),find_in_parent_folders(), and similar functions return that unit's paths.terragrunt info print --allwrites JSON Lines and reports each unit's own download directoryinfo print --allwrote each unit's info indented over several lines, one object after another, and gave every unit the root'sdownload_dir:$ terragrunt info print --all { "config_path": "/example/live/db/terragrunt.hcl", "download_dir": "/example/live/.terragrunt-cache", "iam_role": "", "terraform_binary": "tofu", "terraform_command": "print", "working_dir": "/example/live/.terragrunt-cache/EfNrjc2equLKYmOZbwT2qu1dO9c/ByrgT1vMBQjFneXYgAxchposVZ0" } { "config_path": "/example/live/vpc/terragrunt.hcl", "download_dir": "/example/live/.terragrunt-cache", ... }A line-oriented reader could not take one entry at a time:
The
download_dirwas wrong as well.run --allcreates each unit's.terragrunt-cachenext to that unit's configuration, so the directory reported here was not the one the unit runs against.With
--all, Terragrunt now writes one object per line, so the output is JSON Lines, and builds each unit's context the wayrun --alldoes:Printing a single unit is unchanged: one indented object.
Malformed
excludeblocks report an errorTerragrunt silently dropped an
excludeblock with an attribute of the wrong type, such asactions = "plan"where a list belongs, and ran the unit as if the block weren't there. The parse now fails with an error that names the file and the attribute:Discovery doesn't fetch dependency outputs, so it can't evaluate an
excludeblock that reads one. Terragrunt still skips that block during discovery, and now logs a warning naming the file.Dependencies on a stack skip its disabled units
A
dependencywhoseconfig_pathpointed at a stack directory also depended on the units and stacks in that stack set toenabled = false. Stack generation never writes a disabled unit, sorun --allfailed on the missing directory:find --dependenciesanddag graphlisted the same missing path as a dependency.The dependency now covers only enabled units. The units of a disabled stack are left out, including a tree generated before the stack was disabled.
Stack commands respect
--discovery-boundarystack generate,stack run, andstack outputscanned the whole working directory for stack files and ignored--discovery-boundary. In a monorepo with a catalog next to live infrastructure, a catalog stack referencing files that exist only in the live tree failed the command, even though the command never asked for that stack.The boundary now applies to these commands, including an inline
(dir)operand, and it holds when a Git expression such as[main...HEAD]generates stacks for both compared commits. This works from the repository root:terragrunt stack run plan --filter '(./live/)...[main...HEAD]'Terragrunt skips the catalog units outside
./live. It still scans the whole working directory when a positive filter has no dependent-side boundary and--discovery-boundaryis unset, or when the boundaries fall in separate directories.Dependent discovery had the same gap and parsed units outside the dependent-side boundary. It now starts the search for dependents at that boundary, which can be a directory inside the working directory.
In a Git expression, a relative boundary resolves against the repository root like any other path in the expression. Changed units outside a dependent-side boundary are ignored, and a boundary that exists in neither compared commit is an error. A dependency-side boundary only limits dependency traversal.
--auth-provider-cmdand--queue-construct-asreject unquoted shell operatorsTerragrunt splits
--auth-provider-cmdand--queue-construct-asvalues into words without running a shell. An unquoted shell operator such as|,;,&&, or>used to end the value, and Terragrunt used only the words before it, so--auth-provider-cmd 'get-creds | jq .creds'ranget-credson its own.A value with an unquoted shell operator is now an error. Quote the operator to pass it as part of an argument. To run a pipeline as the auth provider, put it in a script and pass the script.
🧪 Experiments Added
mcp-command— Serve Terragrunt operations to AI agentsThe new
mcp-commandexperiment adds themcpcommand, which serves Terragrunt operations to AI agents over the Model Context Protocol.An agent can ask which units exist, how they depend on each other, whether configurations pass validation, what order the units run in, what a unit's applied outputs are, and more.
Point an MCP client at the Terragrunt binary and make sure that it enables the experiment:
By default, the server refuses to start any subprocess (e.g.
tofu,terraform,git, or arun_cmdprogram). Wherever Terragrunt would have started one, the result substitutes a stand-in for its output, such asmock_outputsfor a dependency output thattofu output -jsonwould have fetched, and lists each substitution in adegradedfield.Pass
--allow=execto let the server run thetofu,terraform, andgitthat Terragrunt starts on its own during a run. A program a configuration names, throughrun_cmd(), abefore_hook, or--auth-provider-cmd, is still refused, including atofu,terraform, orgitthe configuration names for itself, so pointing the server at a repository does not hand it those programs. Allow the commands you want with--allow-cmd, a pattern matched against the program and each of its arguments (e.g.--allow-cmd='jq **'), or let the read-only tools ask: whendiscover,render_config,validate, orrun_ordermeets a refused program, it sends the client an elicitation naming it, which the client usually shows the person operating the agent, and runs again with whatever they accept.plan,apply, anddestroynever ask, since answering would mean running them a second time.The remaining capabilities are denied the same way, each granted on its own:
--allow=httplets Terragrunt make HTTP requests on its own.This includes downloading a unit's remote
terraform { source }, fetching a stack's sources, reaching a cloud API to assume a role or read a bucket, and reading remote state directly from blob stores.--allow=sopslets it decrypt SOPS-encrypted files.Unless it is granted,
sops_decrypt_filefails rather than handing an agent the cleartext of your secrets.--allow=envpasses the server's environment variables to configurations and the commands the tools run.Unless it is granted, tool calls start from an empty environment, so
get_env()returns its default. The server also clears its own environment variables and pointsHOMEat an empty directory, so cloud SDKs, the SOPS decrypter, andgitcommands Terragrunt runs will find no credentials in environment variables or your home directory.Granting a capability only changes the capabilities of Terragrunt. A process started under
--allow=execcan still reach out on the network on its own, sotofu initwill download providers whether or not--allow=httpwas passed to allow Terragrunt to make network requests. The directory the server is launched in is its root. A tool call targeting a directory outside it is refused, and graph traversal is bounded there too, so a filter following dependencies or dependents cannot bring back a unit from a tree the server was never pointed at. That bounds what the server acts on, not what a configuration can read: an HCL function such asfile()reads the real disk wherever it points.You can grant multiple capabilities at once:
A separate flag,
--dangerously-allow-apply, addsapplyanddestroytools on top of--allow=exec. Without it neither tool is registered, so a client is never told they exist, and the server won't ever runapplyordestroyon behalf of a client.With it, the tool calls return an elicitation (the protocol's way for a server to ask the client's user a question) naming the units that would be run, and the run starts only once the person operating the client accepts it. A decline ends the tool call, and a client with no way to ask anyone is refused. The approval names the units, not the changes: nothing is planned to build that list, since a plan costs a full run that the acceptance then repeats. Call the plan tool first if you want the changes in front of you before accepting.
Only grant this capability on infrastructure you are willing to lose.
Passing it without
--allow=execis refused at startup, since applying means running OpenTofu/Terraform. Launch the server in the environment directory you are willing to have changed rather than at the repository root, because that directory is as far as any tool call can reach:Warning
Agents managing infrastructure
An agent reading your estate is still an agent acting on it. A model can be confidently wrong about what a tool does, and it can be steered by things you don't expect, including the comments in configurations, module READMEs, and command output it was pointed at. Read what an agent responds with as a proposal. Keep a person between it and anything that changes real resources, and give it credentials scoped to what you are willing to have it reach.
The restrictions this server places on itself are not a sandbox. They bound what the tools on this server do, and nothing else. An agent that can run shell commands can run
terragrunt run --all applyitself, with your ambient credentials, whether or not the server was started with--allow=exec.You remain responsible for how your agents manage infrastructure, and for what they do with the access you give them. An agent with these tools and your credentials can change or destroy real resources, and accepting that risk is your decision.
The tools that run OpenTofu/Terraform use the binary named by
--tf-path, and ignore a unit'sterraform_binaryandengineblock, since Terragrunt starts both without an--allow-cmdpattern or an approval.plan,apply, anddestroytakeparallelismto cap how many units run at once.The tools the server offers, the arguments they take, and what each capability grants are documented with the
mcpcommand.This will not stabilize before v1.3, so treat the tool set, the flag names, and the shape of every result as subject to change until then. The experiment documentation lists the criteria that have to be met first.
🧪 Experiments Updated
Eleven experiments completed
The following experiments graduated to general availability in this release, and the features they gated are now enabled by default:
azure-backendblock-iterationbounded-discoverycatalog-formatdependency-fetch-output-from-statemutable-generateocioptional-dependency-outputsoptional-hooksprofilingversion-attributeEach feature is described in the New Features section above.
The corresponding
--experimentflags (andTG_EXPERIMENTvalues) are no longer needed. Passing one still works, but emits a warning about the completed experiment, so you can drop it at your convenience.Thank you to everyone who ran these experiments early and filed the feedback that got them here.
tg-login— Signing in to the Gruntwork Developer PortalThe
tg-loginexperiment now enablesterragrunt login, which signs you in to the Gruntwork Developer Portal from the CLI:Once you are signed in,
terragrunt catalogdiscovers the repositories your organization selected in the portal and adds them to your catalog. See Gruntwork Developer Portal for how to select those repositories.See the experiment documentation for what still has to land before it stabilizes.
⚙️ Process Updates
Dropped the
hashicorp/terraformv0.15.3dependencyTerragrunt drew its built-in functions from
github.com/hashicorp/terraform, pinned to v0.15.3 by areplacedirective. Those functions now come from Terragrunt's own copy of the OpenTofu implementations, andgo.modhas noreplacedirectives.Projects that import Terragrunt as a Go module no longer resolve
github.com/hashicorp/terraform, and their dependency graph drops by roughly 175 modules, most of them cloud provider SDKs that Terraform used for its backends.Installing and running the Terragrunt binary is unchanged.
Pull Requests
✨ Features
logincommand by @yhakbar in #6804terragrunt catalogby @yhakbar in #6937mcpcommand by @yhakbar in #6851🐛 Bug Fixes
--cas-offlinesupport forcatalogby @yhakbar in #6904expansionwithautoincludeby @yhakbar in #6936enabledattribute by @yhakbar in #6939mcpcommand #6851 by @yhakbar in #6991TestStackExpansionGitFilterSelectsRemovedInstanceby @yhakbar in #7004iam_roleper unit directory and erroring on malformedexcludeblocks by @yhakbar in #7012📖 Documentation
mcp.docs.terragrunt.cominstall instructions by @yhakbar in #6984logincommand by @yhakbar in #6996🤖 CI
🧹 Chores
block-iterationexperiment by @yhakbar in #6925bounded-discoveryexperiment by @yhakbar in #6928catalog-formatexperiment by @yhakbar in #6931mutable-generateexperiment by @yhakbar in #6933optional-dependency-outputsexperiment by @yhakbar in #6935version-attributeexperiment by @yhakbar in #6949TestAwsDependencyOutputOptimizationtests by @yhakbar in #6953optional-hooksexperiment by @yhakbar in #6938TestAwstoTestAWSby @yhakbar in #6979GITHUB_STEP_SUMMARYin bats tests to avoid actually writing to summaries by @yhakbar in #7000gotestsumbetter by @yhakbar in #7001multierroruse by @yhakbar in #7016This discussion was created from the release v1.2.0-rc1.
All reactions