Type-Aware Merging of YAML Functions
Atmos supports type-aware merging of YAML functions and concrete values, allowing them to coexist in the inheritance chain without type conflicts.
The Problem: Type Conflicts During Merge
When merging stack configurations, Atmos needs to handle both concrete values and YAML function references. Without special handling, the merge process would encounter type mismatches:
# Base catalog (catalog/app/defaults.yaml)
components:
terraform:
my-app:
vars:
database_url: "postgresql://localhost:5432/mydb" # Concrete string value
# Environment override (stacks/prod/app.yaml)
components:
terraform:
my-app:
vars:
database_url: !env DATABASE_URL # YAML function reference
The YAML function !env DATABASE_URL is a different type than the string "postgresql://localhost:5432/mydb". Without special handling, merging these would cause a type conflict error.
The Solution: Type-Aware Merging
Atmos handles this gracefully through type-aware merging:
- YAML functions are recognized and wrapped in a special type during parsing
- During merge, this allows YAML functions to replace concrete values (and vice versa) without type errors
- YAML functions are evaluated as the final step in stack processing, as they have always been
This approach ensures that YAML functions can override static values throughout the inheritance chain.
Supported Functions
The following YAML functions support type-aware merging:
!env- Environment variables!exec- External command execution!store- Store value retrieval!store.get- Store value retrieval (alias)!template- Template rendering!terraform.output- Terraform output values!terraform.state- Terraform state values