Atmos YAML Functions
YAML Functions are the recommended way to add dynamic behavior to your Atmos configurations. They are native YAML features that work with the YAML parser, making them type-safe, predictable, and error-resistant. Unlike template functions which manipulate raw text, YAML functions operate on structured data after parsing.
Explicit tags and quoted strings
Keep the function tag outside the quotes: foo: !env "SOMETHING" reads the environment
variable, while foo: "!env SOMETHING" is literal text. This applies to all YAML functions
from edition 2026-10-20, including unpinned projects. Earlier editions retain legacy
string-prefix evaluation. See the migration guide.
Using a function value in a template
Templates render before YAML functions run, and Atmos carries the function through rendering so it can fill in the value afterward. This works when a template places the value in a string:
vars:
region: !env AWS_REGION
stage: dev
components:
terraform:
app:
vars:
name: "app-{{ .vars.region }}-{{ .vars.stage }}" # app-us-east-1-dev
The function must return a single value such as a string or number. A map or list inside a larger string fails with an error.
Template functions and conditions on vars run before the value exists. {{ .vars.region | upper }} fails with an
error, and {{ if eq .vars.region "us-east-1" }} compares against the unevaluated function rather than the region.
Declare the function in locals when a template needs to act on the result, as in
{{ .locals.region | upper }}.
Why YAML Functions Are Safer
YAML functions are based on YAML Explicit typing and user-defined Explicit Tags (local data types). Explicit tags are denoted by the exclamation point ("!") symbol.
Key advantages over template functions:
- Cannot break YAML syntax - Functions execute after YAML parsing, not before
- Type-safe - Work with actual YAML types, not raw strings
- No indentation issues - The YAML structure is already established
- Clear error messages - Errors point to specific YAML nodes, not parsing failures
- Predictable behavior - Always return valid YAML data structures
Atmos detects the tags in the stack manifests and executes the corresponding functions.
YAML supports three types of data: core, defined, and user-defined.
- Core types: Universally supported, including floats, integers, strings, lists, and maps.
- Defined types: Advanced types like binary data, specified in the YAML standard but not always supported.
- User-defined types: Custom extensions for classes, structures, and functions. Atmos leverages user-defined types to implement its custom functions and extend YAML's capabilities.
Use-cases
-
The
!starlarkYAML function computes typed configuration values using functions, conditions, and the merged component context. -
The
!appendYAML function concatenates lists during stack inheritance instead of replacing them, providing fine-grained control over list merging behavior on a per-field basis -
The
!terraform.outputYAML function allows you to access component outputs (remote state) directly within Atmos stack manifests. Note that this requires initializing each component (terraform/tofu init), which initializes all Terraform/OpenTofu modules and downloads all Terraform/OpenTofu providers, which may significantly impact performance. Consider using!storeor!terraform.statefunctions instead, which don't have this performance penalty. -
The
!terraform.stateYAML function reads outputs directly from the configured Terraform or OpenTofu backend, without initializing providers or running Terraform — it's very fast and currently supports S3 and local backends for accessing remote state. -
The
!storeYAML function allows reading the values from a remote store (e.g. SSM Parameter Store, Artifactory, etc.) into Atmos stack manifests -
The
!store.getYAML function allows retrieving arbitrary keys directly from a store without following the Atmos stack/component/key naming convention. This is useful for accessing values stored by external systems or for retrieving global configuration that doesn't belong to a specific component. -
The
!includeYAML function allows downloading local or remote files from different sources, and assigning the file contents or individual values to the sections in Atmos stack manifests. -
The
!templateYAML function is designed to evaluate and inject outputs containing maps or lists into the YAML document, whether generated by theatmos.Componenttemplate function or any Go template. -
The
!execYAML function is used to execute shell scripts and assign the results to the sections in Atmos stack manifests. -
The
!envYAML function is used to retrieve environment variables and assign them to the sections in Atmos stack manifests. -
The
!repo-rootYAML function is used to retrieve the root directory of the Atmos repository. -
The
!git.repository,!git.owner,!git.name,!git.host, and!git.urlYAML functions retrieve repository metadata (the<owner>/<name>slug, owner, name, host, and remote URL) from the current Git repository. -
The
!git.sha,!git.ref, and!git.branchYAML functions retrieve the current commit SHA (!git.shaand its source-pinning alias!git.ref) and the current branch name. -
The
!git.rootYAML function is an alias of!repo-rootthat retrieves the root directory of the current Git repository. -
The
!emulatorYAML function retrieves connection information (endpoint, credentials, kubeconfig) from a running emulator component. -
The
!cwdYAML function is used to retrieve the current working directory where Atmos is executed from. Useful when you need paths relative to where you run Atmos rather than relative to the configuration file. -
The
!unsetYAML function is used to delete or remove keys from the configuration during inheritance and merging. This allows you to explicitly remove values that were defined in parent configurations or imports, providing fine-grained control over configuration inheritance -
The
!randomYAML function generates a cryptographically secure random integer within a specified range, useful for generating random port numbers or IDs. -
The
!literalYAML function preserves values exactly as written, bypassing all template processing. Use it to pass template-like syntax (e.g.,{{...}}or${...}) to downstream tools like Terraform, Helm, or ArgoCD without Atmos attempting to evaluate them. It also works inatmos.yamland on thescriptandcommandof custom command, workflow, and hook steps. -
The
!versionYAML function resolves a value from the active Atmos-managed version track lock file. Use it for locked toolchain versions, image tags, GitHub Actions refs, and other external version values. -
The
!aws.account_idYAML function retrieves the AWS account ID of the current caller identity using STS GetCallerIdentity. -
The
!aws.caller_identity_arnYAML function retrieves the full ARN of the current AWS caller identity using STS GetCallerIdentity. -
The
!aws.caller_identity_user_idYAML function retrieves the unique user ID of the current AWS caller identity using STS GetCallerIdentity. -
The
!aws.regionYAML function retrieves the AWS region from the current SDK configuration. -
The
!aws.cloudformation.outputYAML function allows you to read the deployed Outputs of a nativeaws/cloudformationcomponent directly within Atmos stack manifests — the Terraform↔CloudFormation interop bridge, sibling to!terraform.output. -
The
!tagsand!labelsYAML functions return the current component's ownmetadata.tags(list) andmetadata.labels(map), typed correctly with no!template/toJsonboilerplate — commonly used to bridgemetadata.labelsinto thevars.tags/vars.labelsaterraform-null-label-style module expects.!labels.keysand!labels.valuesreturn just the keys or values ofmetadata.labelsas a flat list. Use!labels key [default]to read one label, with an optional fallback when the key is absent. -
The
!ci.labelsYAML function reads the live labels on the current CI pull request (or, for merge queue runs, the queued pull request) and returns either the sorted label list or a boolean for!ci.labels [preview]. Use it to drivesettings.pro.enabled,metadata.enabled, ormetadata.labelsfrom the review, then select with--labels preview:true.
You can combine Atmos Stack Manifest Templating with Atmos YAML functions within the same stack configuration. Post-merge stack value functions can consume component template results. Load-time includes, merge directives, and field-specific functions run at different stages; see YAML function scope and evaluation.
Atmos sections supporting YAML functions
YAML functions work in values that reach the stack/component evaluator, including vars,
settings, env, providers, and backend values. Support is specific to the function and
consumer: import paths and structural fields may be needed before component evaluation,
and workflow fields do not automatically use the stack evaluator.
CLI configuration, stack manifests, workflows, custom commands, hooks, vendor manifests,
and scaffolds have different function sets. Consult the
scope matrix and each function's availability section before
moving an example between them. Run atmos doctor --only yaml-functions to diagnose
unsupported uses without executing the functions.
Examples
Native Atmos YAML Functions
Atmos natively supports the following YAML functions:
Append items to lists during configuration merging
Retrieve the AWS account ID of the current caller identity
Retrieve the ARN of the current AWS caller identity
Retrieve the unique user ID of the current AWS caller identity
Read the deployed Outputs of an aws/cloudformation component directly in Atmos stack manifests
Retrieve the AWS Organization ID of the current account
Retrieve the current AWS region from the SDK configuration
Read live CI review labels or test whether all requested labels are present
Get the current working directory
Retrieve connection information from a running Atmos emulator
Retrieve environment variables from stack manifests or OS environment and assign them to sections in Atmos stack manifests
Execute shell scripts and assign the results to the sections in Atmos stack manifests
Get the current branch name of the current Git repository
Get the host of the current Git repository
Get the bare repository name of the current Git repository
Get the owner/organization of the current Git repository
Get an immutable Git ref of the current repository, suitable for source pinning
Get the repository slug (owner/name) of the current Git repository
Get the root directory of the current Git repository
Get the current HEAD commit SHA of the current Git repository
Get the remote URL of the current Git repository
Download local or remote files from different sources, and insert their contents or specific values directly into sections of your stack manifests
Force inclusion of files as raw strings regardless of their extension or content
Retrieve all component labels or one label by key, with an optional default
Retrieve the current component's own metadata.labels keys as a sorted list
Retrieve the current component's own metadata.labels values as a list, ordered by key
Preserve values exactly as written, bypassing all template processing
Generate a random integer within a specified range
Get the root directory of the Atmos repository
Resolve a declared secret from its configured backend for an Atmos component in a stack
Compute typed configuration values with Starlark and the effective component context.
Read a value from a store for an Atmos component in a stack
Retrieve arbitrary keys directly from a store
Retrieve the current component's own metadata.tags as a list
Handle outputs containing maps or lists returned from the atmos.Component template function
Read the remote state of any Atmos component from Terraform/OpenTofu outputs
The FASTEST way to retrieve Terraform outputs - reads directly from state backends without initializing Terraform or downloading providers
Delete/remove values from Atmos stack configurations
Resolve an Atmos-managed version from the active version track lock file.
Which Atmos YAML functions work in each configuration context, and when they run.