بنقرة واحدة
atmos-templates
// Go templates: Sprig/Gomplate functions, atmos.Component, atmos.GomplateDatasource, atmos.Store, template configuration, evaluations
// Go templates: Sprig/Gomplate functions, atmos.Component, atmos.GomplateDatasource, atmos.Store, template configuration, evaluations
[HINT] تحميل مجلد المهارة الكامل بما في ذلك SKILL.md وجميع الملفات المرتبطة
| name | atmos-templates |
| description | Go templates: Sprig/Gomplate functions, atmos.Component, atmos.GomplateDatasource, atmos.Store, template configuration, evaluations |
| metadata | {"copyright":"Copyright Cloud Posse, LLC 2026","version":"1.0.0"} |
| references | ["references/go-templates.md"] |
Go templates use {{ }} delimiters and are processed before YAML parsing. They support the full
Go text/template syntax plus Sprig and Gomplate function libraries.
Go templates are an escape hatch for complex conditional logic, loops, dynamic key generation, or
advanced string manipulation that YAML functions cannot handle. For most use cases, prefer YAML
functions (see the atmos-yaml-functions skill).
# atmos.yaml
templates:
settings:
enabled: true
evaluations: 1 # Number of processing passes
delimiters: ["{{", "}}"] # Default delimiters
sprig:
enabled: true # Enable Sprig functions
gomplate:
enabled: true # Enable Gomplate functions and datasources
timeout: 5 # Datasource timeout in seconds
In Go templates, you can reference any value from the component's configuration (as returned by
atmos describe component):
| Variable | Description |
|---|---|
.atmos_component | The Atmos component name |
.atmos_stack | The Atmos stack name |
.stack | Alias for .atmos_stack |
.atmos_stack_file | The stack manifest file path |
.workspace | The Terraform workspace name |
.vars.* | Component variables |
.settings.* | Component settings |
.env.* | Environment variables |
.metadata.* | Component metadata |
.providers.* | Provider configuration |
.backend.* | Backend configuration |
.backend_type | Backend type string |
components:
terraform:
vpc:
vars:
tags:
atmos_component: "{{ .atmos_component }}"
atmos_stack: "{{ .atmos_stack }}"
terraform_workspace: "{{ .workspace }}"
# Sprig function
provisioned_by: '{{ env "USER" }}'
# Gomplate function
description: "{{ strings.Title .atmos_component }} in {{ .atmos_stack }}"
atmos.Component Template FunctionReads any section or attribute from another component's configuration, including Terraform outputs:
vars:
# Read outputs (remote state)
vpc_id: '{{ (atmos.Component "vpc" .stack).outputs.vpc_id }}'
# Read variables from another component
vpc_name: '{{ (atmos.Component "vpc" .stack).vars.name }}'
# Read settings
test_setting: '{{ (atmos.Component "test" .stack).settings.test }}'
# Read metadata
component_name: '{{ (atmos.Component "test" .stack).metadata.component }}'
# Complex outputs require !template + toJson
subnet_ids: !template '{{ toJson (atmos.Component "vpc" .stack).outputs.private_subnet_ids }}'
atmos.GomplateDatasource Template FunctionFetches external data with automatic caching:
settings:
templates:
settings:
gomplate:
datasources:
ip:
url: "https://api.ipify.org?format=json"
secret:
url: "aws+smp:///path/to/secret"
vars:
public_ip: '{{ (atmos.GomplateDatasource "ip").ip }}'
db_password: '{{ (atmos.GomplateDatasource "secret").password }}'
The function caches results per execution -- multiple references to the same datasource make only one external call.
atmos.Store Template FunctionReads from stores using Go template syntax (same as !store YAML function but in template form):
vars:
vpc_id: '{{ atmos.Store "prod/ssm" .stack "vpc" "vpc_id" }}'
config: !template '{{ (atmos.Store "redis" .stack "config" "config_map").defaults | toJSON }}'
Atmos supports multiple evaluation passes for template processing:
# atmos.yaml
templates:
settings:
enabled: true
evaluations: 2 # Two passes
With multiple evaluations, output from the first pass becomes input to the second pass. This is useful for:
Use the backtick escape or !literal to prevent Atmos from processing templates intended for
external systems (ArgoCD, Helm, Datadog):
# Using !literal (recommended, see atmos-yaml-functions skill)
annotation: !literal "{{ .Values.ingress.class }}"
# Using backtick escape
annotation: "{{`{{ .Values.ingress.class }}`}}"
# Using printf
annotation: '{{ printf "{{ .Values.ingress.class }}" }}'
When using Go templates in both imports and stack manifests, templates intended for the second pass (stack processing) must be escaped in the import file:
# stacks/catalog/eks/eks_cluster.tmpl
components:
terraform:
eks/cluster:
vars:
# First pass: resolved from import context
enabled: "{{ .enabled }}"
name: "{{ .name }}"
tags:
# Second pass: escaped for stack processing
atmos_component: "{{`{{ .atmos_component }}`}}"
atmos_stack: "{{`{{ .atmos_stack }}`}}"
Template settings can be defined in settings.templates.settings in stack manifests, which
deep-merges with templates.settings in atmos.yaml. Stack manifest settings take precedence.
# stacks/orgs/acme/_defaults.yaml
settings:
templates:
settings:
env:
AWS_PROFILE: "my-profile"
gomplate:
timeout: 7
datasources:
config:
url: "./my-config.json"
Note: enabled, sprig.enabled, gomplate.enabled, evaluations, and delimiters settings
are not supported in stack manifests (only in atmos.yaml).
| Scenario | Use |
|---|---|
| Reading Terraform outputs | YAML functions: !terraform.state or !terraform.output |
| Reading store values | YAML functions: !store or !store.get |
| Environment variables | YAML function: !env |
| Including files | YAML function: !include |
| Complex outputs (lists/maps) | !template with toJson |
Conditional logic (if/else) | Go templates |
| Loops and iteration | Go templates |
| Dynamic key generation | Go templates |
| External API data | atmos.GomplateDatasource |
| Advanced string manipulation | Go templates with Sprig/Gomplate |
!store over atmos.Component for outputs -- Avoids Terraform initializationatmos.GomplateDatasource instead of datasource -- Built-in caching prevents
redundant API callsatmos.Component usage -- Each call may initialize Terraform{{ }} can cause YAML parse errors. Always quote
template expressions.!template with toJson for
complex types.env function exists in both libraries with different
syntax. Use getenv for Gomplate's version when both are enabled.atmos.Component or !terraform.output across
many stacks can dramatically slow atmos describe stacks and atmos describe affected.!terraform.state, !store, !env, etc.), see the atmos-yaml-functions skill