Atmos YAML Functions
Atmos YAML Functions are a crucial part of Atmos stack manifests. They allow you to manipulate data and perform operations on the data to customize the stack configurations.
Atmos 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. 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
!template
YAML function is designed to evaluate and inject outputs containing maps or lists into the YAML document, whether generated by theatmos.Component
template function or any Go template. -
The
!exec
YAML function is used to execute shell scripts and assign the results to the sections in Atmos stack manifests -
The
!terraform.output
YAML function allows you to
access component outputs (remote state) directly within Atmos stack manifests.
Note that this requires initializing each component (terraform init
), which downloads all Terraform providers and may significantly impact performance.
You can combine Atmos Stack Manifest Templating with Atmos YAML functions within the same stack configuration. Atmos processes templates first, followed by YAML functions, enabling you to dynamically provide parameters to the YAML functions.
Atmos sections supporting YAML functions
You can use the YAML functions in all Atmos stack manifest sections:
vars
settings
env
metadata
command
component
providers
overrides
backend
backend_type
remote_state_backend
remote_state_backend_type
Examples
stack.yaml
Native Atmos YAML Functions
Atmos natively supports the following YAML functions:
📄️ !template
Handle outputs containing maps or lists returned from the atmos.Component template function
📄️ !exec
Execute shell scripts and assign the results to the sections in Atmos stack manifests
📄️ !terraform.output
Read the remote state of any Atmos component