Locals Context Access
· One min read
Locals can access {{ .settings }}, {{ .vars }}, and {{ .env }} from the same file during template resolution.
The Enhancement
Previously, locals could only reference other locals via {{ .locals.* }}. Now they can also access:
{{ .settings.* }}- Settings defined in the same file{{ .vars.* }}- Vars defined in the same file{{ .env.* }}- Environment variables
Example
settings:
version: v1
vars:
stage: dev
locals:
namespace: acme
label: "{{ .locals.namespace }}-{{ .vars.stage }}-{{ .settings.version }}"
components:
terraform:
myapp:
vars:
name: "{{ .locals.label }}"
See it resolve with structured values:
00:00.0 / 00:00.0
File-Scoped Context
The context available to locals comes from the same file only. Locals cannot access settings or vars from imported files.
If you need values from imported files, use vars or settings (which inherit across imports).
Upgrade
Upgrade Atmos to get this enhancement. Existing locals configurations will continue to work.
Try it out
- Install Atmos
- Try the example
Copy the example into a new directory and make it your own:
atmos init examples/locals
cd locals
Inspect the file-scoped locals resolved for the development stack.
atmos describe locals -s dev
