You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Atmos attempts to template within TF modules resulting in error #2145
I noticed that when using Atmos on some Terraform modules (vendored or self-written), they would immediately error out:
Error: template: templates-all-atmos-sections:156: function "project" not defined
After some digging, it turns out this happens when the module contains anything that looks like a Go template. i.e. some manifest or variable/output description containing double curly braces. Some Terraform vendors (GCP especially) just do this for specifying the format of values.
output"service_id" {
value=google_cloud_run_v2_service.main.iddescription="Unique Identifier for the created service with format projects/{{project}}/locations/{{location}}/services/{{name}}"
}
Expected Behavior
Atmos Go templating should happen in the abstraction above Terraform modules. Configure Atmos to ignore double curly brace sequences that may occur in Terraform modules.
Steps to Reproduce
In the Atmos repo, go to examples/quick-start-simple
Modify components/terraform/weather/*.tf, such as adding a description containing double curly braces.
output"url" {
value=local.urldescription="URL in the format https://{{domain}}/{{foobar}}"
}
Run atmos terraform plan station -s dev
Receive vague error occurs about undefined templating function
Error: template: templates-all-atmos-sections:156: function "domain" not defined
Confirmed reproducible on main (commit at HEAD of main)
Reproduced with the user's exact command after adding the {{ }} description to an output in examples/quick-start-simple/components/terraform/weather/outputs.tf:
$ atmos terraform plan station -s dev
# Error
**Error:** template: templates-all-atmos-sections:184: function "domain" not defined
(Line number differs from the reporter's :156 — depends on the exact YAML structure of the component section — but the error class is identical.)
One nuance worth flagging: the reproduction requires templates.settings.enabled: true in atmos.yaml. With the default (enabled: false), the templating step is skipped and the .tf description passes through harmlessly. The reporter's steps don't mention enabling templating, so either their atmos.yaml (not shown in the report) has it on, or they reduced the repro and dropped that detail. Either way, the bug fires for any project that has templating enabled — which is the configuration most users running on stack-level Go templates are in.
In the component-info block, Atmos reads the .tf files with terraform-config-inspect and attaches the parsed module to ComponentSection["component_info"]:
terraform-config-inspect returns the variables' and outputs' description fields verbatim. Then a few dozen lines earlier, when processTemplates is true, Atmos serializes the whole ComponentSection to YAML and runs it through Go templating:
So the description = \"…{{domain}}…\" from the .tf file ends up inside the YAML string being templated, Go's text/template parses {{domain}} as a function call, and fails with function \"domain\" not defined.
This is consistent with the reporter's analysis: the templating contract is supposed to be "stack manifests only," but the component_info.terraform_config section silently smuggles arbitrary user-authored HCL description strings into the templated input.
I confirmed describe component station -s dev --format yaml (which doesn't run templating) shows the raw description intact:
url_doc:
name: url_docdescription: URL in the format https://{{domain}}/{{foobar}}
So the data flow is real — the .tf content is being merged into ComponentSection. The bug is purely on the templating pass.
Suggested fix directions
Three reasonable angles, ordered from narrowest to broadest:
Exclude component_info from the YAML that goes into templates-all-atmos-sections. This is the highest-value section to not template — its content is HCL-parsed module metadata, not Atmos stack manifest data, and there is no documented use case for templating descriptions/variable types/output names. Implementation: clone ComponentSection before serializing, delete the component_info key (or just the component_info.terraform_config subkey), serialize, template the result, then re-attach the original component_info. Smallest blast radius. Doesn't change behavior for any stack-manifest-level template usage.
Treat module metadata descriptions as literal strings during templating. Walk terraformConfiguration before attaching it to componentInfo and escape any {{/}} in description/string fields (e.g., via the same delimiter-preservation mechanism the YAML encoder already uses to handle custom delimiters per !terraform.state fails with templated arguments when custom delimiters include quotes #2052). More involved and intrusive; users would lose the ability to intentionally template values inside descriptions, but no one is documented to rely on that.
Drop terraform-config-inspect's output from ComponentSection entirely.component_info.terraform_config is consumed by a handful of places (OPA/JSON Schema validation, describe output). Audit those consumers; if none rely on the parsed module structure being present, move it out of ComponentSection and only attach it to flows that need it. Cleanest architecturally, biggest blast radius.
(1) is the smallest correct fix and lines up with the documented contract (templating is for stack manifests, not Terraform source). The reporter's expectation — "Atmos Go templating should happen in the abstraction above Terraform modules" — maps directly to (1).
Related issue
The same tfconfig.LoadModule path also surfaces in #1864 (component-not-found masking a real HCL parse error); the fix in this area should be careful not to regress that error-handling logic, which now lives in the diags.HasErrors() branch at internal/exec/utils.go:920-980.
Activity
thejrose1984 commentedon May 29, 2026
Confirmed reproducible on
main(commit at HEAD ofmain)Reproduced with the user's exact command after adding the
{{ }}description to an output inexamples/quick-start-simple/components/terraform/weather/outputs.tf:(Line number differs from the reporter's
:156— depends on the exact YAML structure of the component section — but the error class is identical.)One nuance worth flagging: the reproduction requires
templates.settings.enabled: trueinatmos.yaml. With the default (enabled: false), the templating step is skipped and the.tfdescription passes through harmlessly. The reporter's steps don't mention enabling templating, so either theiratmos.yaml(not shown in the report) has it on, or they reduced the repro and dropped that detail. Either way, the bug fires for any project that has templating enabled — which is the configuration most users running on stack-level Go templates are in.Root cause
The path:
terraform plan→ProcessStacks(... processTemplates=true, ...)→ block at internal/exec/utils.go:912-996 → templating block at internal/exec/utils.go:779-815.In the component-info block, Atmos reads the
.tffiles with terraform-config-inspect and attaches the parsed module toComponentSection["component_info"]:terraform-config-inspectreturns the variables' and outputs'descriptionfields verbatim. Then a few dozen lines earlier, whenprocessTemplatesis true, Atmos serializes the wholeComponentSectionto YAML and runs it through Go templating:So the
description = \"…{{domain}}…\"from the.tffile ends up inside the YAML string being templated, Go'stext/templateparses{{domain}}as a function call, and fails withfunction \"domain\" not defined.This is consistent with the reporter's analysis: the templating contract is supposed to be "stack manifests only," but the
component_info.terraform_configsection silently smuggles arbitrary user-authored HCLdescriptionstrings into the templated input.I confirmed
describe component station -s dev --format yaml(which doesn't run templating) shows the raw description intact:So the data flow is real — the
.tfcontent is being merged intoComponentSection. The bug is purely on the templating pass.Suggested fix directions
Three reasonable angles, ordered from narrowest to broadest:
Exclude
component_infofrom the YAML that goes intotemplates-all-atmos-sections. This is the highest-value section to not template — its content is HCL-parsed module metadata, not Atmos stack manifest data, and there is no documented use case for templating descriptions/variable types/output names. Implementation: cloneComponentSectionbefore serializing, delete thecomponent_infokey (or just thecomponent_info.terraform_configsubkey), serialize, template the result, then re-attach the originalcomponent_info. Smallest blast radius. Doesn't change behavior for any stack-manifest-level template usage.Treat module metadata descriptions as literal strings during templating. Walk
terraformConfigurationbefore attaching it tocomponentInfoand escape any{{/}}in description/string fields (e.g., via the same delimiter-preservation mechanism the YAML encoder already uses to handle custom delimiters per!terraform.statefails with templated arguments when custom delimiters include quotes #2052). More involved and intrusive; users would lose the ability to intentionally template values inside descriptions, but no one is documented to rely on that.Drop
terraform-config-inspect's output fromComponentSectionentirely.component_info.terraform_configis consumed by a handful of places (OPA/JSON Schema validation, describe output). Audit those consumers; if none rely on the parsed module structure being present, move it out ofComponentSectionand only attach it to flows that need it. Cleanest architecturally, biggest blast radius.(1) is the smallest correct fix and lines up with the documented contract (templating is for stack manifests, not Terraform source). The reporter's expectation — "Atmos Go templating should happen in the abstraction above Terraform modules" — maps directly to (1).
Related issue
The same
tfconfig.LoadModulepath also surfaces in #1864 (component-not-found masking a real HCL parse error); the fix in this area should be careful not to regress that error-handling logic, which now lives in thediags.HasErrors()branch atinternal/exec/utils.go:920-980.fix: don't process Go templates in Terraform source code (#2145) (#2830)
fix: skip provenance during component rendering (#2829)
feat: dependency-closure selection (--include-dependencies/--include-…