Explicit inherit requirement introduced in Terramate 0.12 for stack variable propagation
0 reputation · 20 Oct 2021, 14:06 UTC
0 reputation · 20 Oct 2021, 14:06 UTC
Goal: Determine the exact scope of the explicit inherit block requirement added in Terramate 0.12 and identify whether any variable sources remain exempt from this rule.
Constraints: The change affects all projects using Terramate 0.12 or later, modifies existing terramate.hcl files that previously relied on implicit parent‑to‑child variable propagation, and can cause CI/CD failures if the inherit blocks are not added.
Uncertainty: While the documentation states that variables must be declared with an explicit inherit block, it is not clear if this applies universally to Terraform input variables, environment variables, or variables defined by generators and scripts, or if certain sources still allow implicit access.
Starting with Terramate 0.12, variable propagation from a parent stack to a child stack is no longer implicit. A child stack must declare an explicit inherit block to receive any variables that are defined in a parent’s vars block. This change affects all Terramate HCL files and will cause “variable not found” errors if the inherit block is omitted.
vars block are only visible to a child when the child contains an inherit block that lists those variable names (or uses inherit {} to inherit all).terramate.hcl file as well: if the root defines a vars block, child stacks still need an inherit block to access those variables..tf files) and environment variables are managed outside Terramate’s variable‑propagation mechanism; they do not require an inherit block.The documentation states that the inherit block is required for “variables defined in parent stacks.” Based on the internal design, this rule is limited to variables that originate from a vars block anywhere in the inheritance chain. Variables that are:
-var flags) or declared in .tf files,$MY_VAR), orare not subject to the inherit requirement because they never travel through Terramate’s variable‑propagation system.
terramate version (must be 0.12 or higher).vars block (e.g., vars { my_var = "value" }).my_var without an inherit block and run terramate run; you should see a “variable not found” error.inherit {} or inherit { my_var }) and re‑run; the variable should be accessible.-var"my_var=…") or an environment variable; the child stack should read it without any inherit block.If you are observing errors with variables that come from a generator or script output, please confirm whether the variable is being read from the generated file (static value) or accessed via Terramate’s {{ var }} syntax, as this determines whether the inherit block is needed.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.