Loading...
Loading...
YAML functions: !terraform.state, !terraform.output, !store, !store.get, !env, !exec, !include, !template, !literal, !random, !aws.*, !cwd, !repo-root
npx skill4agent add cloudposse/atmos atmos-yaml-functions!| Function | Purpose |
|---|---|
| Read Terraform outputs directly from state backend (fastest, recommended) |
| Read Terraform outputs via |
| Read values from stores using component/stack/key pattern |
| Read arbitrary keys from stores (no naming convention required) |
| Read environment variables (from stack |
| Execute shell scripts and use the output |
| Include local or remote files (YAML, JSON, HCL, text) |
| Include files as raw text regardless of extension |
| Evaluate Go template expressions and convert JSON to YAML types |
| Preserve values verbatim, bypassing all template processing |
| Generate cryptographically secure random integers |
| Get the current working directory |
| Get the repository root directory |
| Get the current AWS account ID via STS |
| Get the current AWS caller identity ARN |
| Get the AWS caller identity user ID |
| Get the current AWS Organization ID |
| Get the current AWS region from SDK config |
varssettingsenvmetadatacommandcomponentprovidersoverridesbackendbackend_typeremote_state_backendremote_state_backend_type!terraform.state!terraform.outputvars:
# Two-parameter form: component + output (current stack)
vpc_id: !terraform.state vpc vpc_id
# Three-parameter form: component + stack + output
vpc_id: !terraform.state vpc plat-ue2-prod vpc_id
# Using Go templates for dynamic stack references
vpc_id: !terraform.state vpc {{ .stack }} vpc_id
# YQ expressions for complex outputs
first_subnet: !terraform.state vpc .private_subnet_ids[0]
db_host: !terraform.state config .config_map.username
# Default values for unprovisioned components
vpc_id: !terraform.state vpc ".vpc_id // ""default-vpc"""
# YQ string concatenation
url: !terraform.state aurora-postgres ".master_hostname | ""jdbc:postgresql://"" + . + "":5432"""
# Bracket notation for keys with special characters
key: !terraform.state security '.users["github-dependabot"].access_key_id'!terraform.outputterraform output!terraform.state!terraform.statevars:
vpc_id: !terraform.output vpc vpc_id
vpc_id: !terraform.output vpc plat-ue2-prod vpc_id
vpc_id: !terraform.output vpc {{ .stack }} vpc_id
first_subnet: !terraform.output vpc .private_subnet_ids[0]!storevars:
vpc_id: !store prod/ssm vpc vpc_id
vpc_id: !store prod/ssm plat-ue2-prod vpc vpc_id
vpc_id: !store prod/ssm {{ .stack }} vpc vpc_id
api_key: !store prod/ssm config api_key | default "not-set"
db_host: !store prod/ssm config connection | query .host!store.getvars:
db_password: !store.get ssm /myapp/prod/db/password
feature_flag: !store.get ssm /features/new-feature | default "disabled"
api_key: !store.get redis app-config | query .api.key
config: !store.get redis "config-{{ .vars.region }}"!envenv:vars:
api_key: !env API_KEY
app_name: !env APP_NAME my-app
description: !env 'APP_DESC "my application"'env:!execvars:
timestamp: !exec date +%s
# Multi-line script
result: |
!exec
foo=0
for i in 1 2 3; do
foo+=$i
done
echo $foo
# Complex types must be returned as JSON
config: !exec get-config.sh --format json!includevars:
config: !include ./config.yaml
vpc_defaults: !include stacks/catalog/vpc/defaults.yaml
region_config: !include https://raw.githubusercontent.com/org/repo/main/config.yaml
cidr: !include ./vpc_config.yaml .vars.ipv4_primary_cidr_block
vars: !include config/prod.tfvars
description: !include ./description.mdgithub://s3::gcs::!templateatmos.Componentvars:
subnet_ids: !template '{{ toJson (atmos.Component "vpc" .stack).outputs.private_subnet_ids }}'
config: !template '{{ toJson (atmos.Component "config" .stack).outputs.config_map }}'
cidrs: !template '{{ toJson .settings.allowed_ingress_cidrs }}'!literalvars:
annotation: !literal "{{ .Values.ingress.class }}"
user_data: !literal "#!/bin/bash\necho ${hostname}"
config_url: !literal "{{external.config_url}}"!randomvars:
port: !random 1024 65535
id: !random 1000 9999
default_random: !randomvars:
account_id: !aws.account_id
org_id: !aws.organization_id
caller_arn: !aws.caller_identity_arn
caller_user_id: !aws.caller_identity_user_id
region: !aws.regionvars:
working_dir: !cwd
repo_root: !repo-root| Scenario | Use |
|---|---|
| Reading Terraform outputs | |
| Reading store values | |
| Environment variables | |
| Including files | |
| Complex outputs (lists/maps) | |
| Passing syntax to external tools | |
Conditional logic ( | Go templates (see |
| Loops and iteration | Go templates (see |
| Dynamic key generation | Go templates (see |
| Advanced string manipulation | Go templates (see |
!terraform.state!terraform.output!storeatmos.Component!terraform.output!store//| default