Skip to main content

Templates

Atmos supports Go templates in stack manifests, along with Sprig and Gomplate functions. Configure template processing and define datasources for dynamic configuration.

Configuration​

Templates are configured in the templates section:

atmos.yaml
# https://pkg.go.dev/text/template
templates:
settings:
enabled: true
# https://masterminds.github.io/sprig
sprig:
enabled: true
# https://docs.gomplate.ca
# https://docs.gomplate.ca/functions
gomplate:
enabled: true
experimental: false
# Timeout in seconds to execute the datasources
timeout: 5
# https://docs.gomplate.ca/datasources
datasources:
# 'http' datasource
# https://docs.gomplate.ca/datasources/#using-file-datasources
ip:
url: "https://api.ipify.org?format=json"
# https://docs.gomplate.ca/datasources/#sending-http-headers
# https://docs.gomplate.ca/usage/#--datasource-header-h
headers:
accept:
- "application/json"
# 'file' datasources
# https://docs.gomplate.ca/datasources/#using-file-datasources
config-1:
url: "./config1.json"
config-2:
url: "file:///config2.json"

Settings​

With no edition pin, or a pin on or after 2026-10-26, stack template processing, Sprig, and Gomplate default to enabled when omitted from atmos.yaml. Earlier editions preserve the disabled defaults for configurations that omit these keys. Explicit values take precedence over edition defaults. The fallback used when no CLI configuration file exists already enabled all three and remains unchanged.

templates.settings.enabled

A boolean flag to enable/disable the processing of Go templates in Atmos stack manifests. Defaults to true. If set to false, Atmos will not process Go templates in stack manifests.

templates.settings.sprig.enabled

A boolean flag to enable/disable Sprig Functions in Atmos stack manifests. Defaults to true.

templates.settings.gomplate.enabled

A boolean flag to enable/disable Gomplate Functions and Gomplate Datasources in Atmos stack manifests. Defaults to true.

templates.settings.gomplate.timeout

Timeout in seconds to execute Gomplate Datasources. Defaults to 5. A stack manifest can override it in settings.templates.settings.gomplate.timeout; otherwise this value applies.

templates.settings.gomplate.experimental

Enables experimental Gomplate functions, such as net.CIDRHost. Defaults to false.

Set globally in atmos.yaml or override per stack with settings.templates.settings.gomplate.experimental. Stacks inherit the global value when omitted; an explicit false disables experimental functions for that stack. Import templates use the global value. Does not apply to document generation or scaffold templates.

templates.settings.ignore_missing_template_values

A boolean flag to globally ignore missing template values across all stack manifest imports. Defaults to false. When set to true, Atmos will not fail if a Go template variable is missing in any imported stack manifest — the missing variable will render as an empty string instead of producing an error. This is equivalent to setting ignore_missing_template_values: true on every individual import, but applied globally. The per-import ignore_missing_template_values setting takes precedence and can be used to override the global default.

This is especially useful when importing catalog manifests that use Go templates for external systems (e.g. Datadog) where not all template variables need to be provided by Atmos.

atmos.yaml
templates:
settings:
ignore_missing_template_values: true

Datasources​

The templates.settings.gomplate.datasources setting is a map of Gomplate Datasource definitions:

  • The keys of the map are the datasource names, which are used in Go templates in Atmos stack manifests
  • The values of the map are the datasource definitions

Datasource Schema​

Each datasource definition supports the following properties:

url

The Datasource URL. Can be an HTTP URL, file path, or other supported URL schemes.

headers

A map of HTTP request headers for the http datasource. The keys of the map are the header names. The values of the map are lists of values for the header.

Using Datasources in Templates​

terraform:
vars:
tags:
provisioned_by_ip: '{{ (datasource "ip").ip }}'
config1_tag: '{{ (datasource "config-1").tag }}'
config2_service_name: '{{ (datasource "config-2").service.name }}'

Available Template Functions​

Atmos supports the following template functions and data sources:

tip

For more details, refer to Atmos Stack Manifest Templating

Function Conflicts​

warning

Some functions are present in both Sprig and Gomplate.

For example, the env function has the same name in Sprig and Gomplate, but has different syntax and accepts different numbers of arguments.

If you use the env function from one templating engine and enable both Sprig and Gomplate, it will be invalid in the other templating engine, and an error will be thrown.

For this reason, you can use the templates.settings.sprig.enabled and templates.settings.gomplate.enabled settings to selectively enable/disable the Sprig and Gomplate functions.

Removed and Renamed Gomplate Functions​

Atmos embeds Gomplate v5. Functions that Gomplate deprecated in v3 were removed upstream in v4, so templates written against older Atmos releases reference names that no longer exist in Gomplate itself. Atmos keeps every one of them working through a compatibility shim: the old name still runs with its Gomplate v3 behavior and logs a warning naming the replacement to switch to. The replacement is not always a drop-in: some take their arguments in a different order or return a different type, as noted for each function below. A bare alias that Sprig provides (such as contains) resolves to Sprig without a warning, as it did before.

A stack manifest rendered as a whole (for example, an import with context) is named in the warning, once per manifest per function. Component configuration is rendered after Atmos merges every manifest that contributes to it, so there is no single manifest to name: those warnings appear once per function per run, under the name of the rendering step. Search your stacks for the function name to find each call. The shim is a bridge, not a long-term guarantee — it will be removed in a future major release of Atmos, so treat the warning as a to-do, not background noise. Each removed function has a direct replacement:

conv.Bool
Use conv.ToBool.
conv.Slice, conv.Dict, conv.Has
Use coll.Slice, coll.Dict, and coll.Has.
strings.Sort
Use coll.Sort.
net.ParseIP, net.ParseIPPrefix, net.ParseIPRange
Use net.ParseAddr, net.ParsePrefix, and net.ParseRange. The old names still work, warn, and return their v3 types (netaddr.IP, netaddr.IPPrefix, and netaddr.IPRange), so their methods keep working. The replacements return netip.Addr, netip.Prefix, and netipx.IPRange, which have different methods.
slice, contains, hasPrefix, hasSuffix, split, splitN, trim (bare aliases)

Gomplate no longer registers these unqualified names. Use the namespaced forms (coll.Slice, strings.Contains, strings.HasPrefix, strings.HasSuffix, strings.Split, strings.SplitN, strings.Trim), and check the argument order when you switch. Gomplate's bare aliases, and the Atmos shims that serve them when Sprig is disabled, take the input first; the strings.* functions take it last so they work in pipelines. For example, contains "alphabet" "pha" becomes strings.Contains "pha" "alphabet", and splitN "a,b,c" "," 2 becomes strings.SplitN "," 2 "a,b,c". coll.Slice takes the same arguments as slice.

When templates.settings.sprig.enabled is true (the default), the bare slice, contains, hasPrefix, hasSuffix, split, and trim names keep working through Sprig, which defines functions of the same name (note that Sprig's argument order differs from Gomplate's in some cases) — Atmos doesn't warn in that case, since Sprig owns the name and nothing changed. With Sprig disabled, Atmos's compatibility shim serves the old Gomplate argument order and warns instead. The bare slice name works the same way: Sprig's slice when Sprig is enabled, and Gomplate's slice (build a list from its arguments, not Go's builtin) with a warning when Sprig is disabled. There is no Sprig fallback for splitN, so the shim covers it either way.

Two further upstream changes affect existing templates:

  • Conversion functions such as conv.ToInt64, conv.ToFloat64, and conv.Atoi (and the functions built on them) now return an error on input they cannot convert, instead of silently returning 0. Atmos does not restore the old silent-zero behavior; the error message includes a hint to guard the call with if or a default.
  • The regexp.* functions return an error for an invalid pattern instead of panicking.

Two datasource behaviors also changed upstream. Atmos can't emulate either one, so instead it warns when it recognizes the pattern in your stack manifests, naming the fix:

  • An aws+smp:// (AWS SSM Parameter Store) datasource now returns the parameter value directly instead of a struct with a Value field. Drop the trailing .Value from calls like (ds "param").Value; add ?type=application/json to the datasource URL if you need the value parsed as JSON.
  • A sub-path argument to ds/datasource/include (for example ds "config" "nested/file.yaml") is now resolved as a relative URL against the datasource's own URL, so the datasource URL must end with / to be treated as a directory.

The boltdb:// datasource scheme was removed upstream with no replacement; Atmos warns if a configured datasource still uses it.

Gomplate v5 also adds the semver.* namespace for parsing and comparing semantic versions.

See Also​