Using External Stores
The !store YAML function reads data from external key-value stores like AWS SSM Parameter Store,
AWS Secrets Manager, Artifactory, Redis, and other backends. Use this when you need to share data outside Terraform state
or publish Terraform outputs to a store with an Atmos hook.
When to Use Stores vs Terraform State
- Use
!terraform.statefor reading Terraform outputs (recommended) - Use
!storefor reading from external systems like SSM, Artifactory, or other key-value stores
You will learn
- Read from external key-value stores (SSM, Secrets Manager, Redis, Artifactory, etc.)
- Configured in
atmos.yamlwith named store definitions - Supports default values for missing keys
- Works with YQ expressions for complex data
When to Use Stores
Use !store when you need to:
- Access configuration stored in SSM Parameter Store
- Share data that isn't managed by Terraform
- Integrate with external configuration management systems
- Store and retrieve data using Artifactory or Redis
For Terraform outputs, use !terraform.state instead.
Configuring Stores
Define stores in your atmos.yaml:
atmos.yaml
Basic Usage
Read values from a configured store:
stacks/prod.yaml
Syntax
# Get key from store for component in current stack
!store <store_name> <component> <key>
# Get key from store for component in a different stack
!store <store_name> <stack> <component> <key>
# With default value
!store <store_name> <component> <key> | default <default-value>
# With YQ query
!store <store_name> <component> <key> | query <yq-expression>
Cross-Stack References
Read from stores for components in different stacks:
stacks/prod.yaml
Default Values
Provide fallback values for missing keys:
# String default
api_endpoint: !store ssm/prod api endpoint | default "https://api.example.com"
# The default is used if the key doesn't exist in the store
feature_flag: !store ssm/prod config feature_enabled | default false
Working with Complex Data
Use YQ expressions to extract values from structured data:
# Get a specific field from JSON stored in the store
db_host: !store ssm/prod database config | query .host
# Get first item from a list
primary_endpoint: !store ssm/prod cluster endpoints | query .[0]
# Navigate nested structures
api_key: !store ssm/prod app credentials | query .api.production.key