| name | atmos-stacks | ||||
|---|---|---|---|---|---|
| description | Stack configuration: local and remote imports, inheritance, deep merging, locals, vars, settings, metadata, overrides, dependencies, and modernization | ||||
| metadata |
|
Stacks are YAML configuration files that define which components to deploy, with what settings, and how they relate to each other. They separate configuration from infrastructure code, enabling the same Terraform root modules to be deployed across many environments with different settings.
A stack manifest is a YAML file that declares components and their configuration for a specific combination of organization, tenant, account, region, and stage. Atmos discovers stack manifests based on included_paths and excluded_paths in atmos.yaml, then deep-merges all imported configurations to produce the final resolved state for each component.
Stacks are not Terraform workspaces, although Atmos derives workspace names from stack names. A single stack manifest can configure multiple components, and a single component can appear across many stacks with different variable values.
| Need | Load |
|---|---|
| Local and remote import mechanics | atmos-imports |
| Modernizing legacy stack patterns | atmos-modernization |
| YAML function inventory | atmos-yaml-functions |
| Component source provisioning | atmos-components |
Atmos discovers stack manifests based on included_paths and excluded_paths configured in the stacks section
of atmos.yaml. For root config discovery and routing, see the atmos-config skill; for path layout
and base_path behavior, see atmos-project-layout.
Atmos resolves the stack name using this priority (highest first):
namefield in the stack manifest (explicit override).name_templateinatmos.yaml(Go template).- Legacy
name_patterninatmos.yaml(migration-only; recommendname_templateor explicitname). - File basename (e.g.,
prod.yamlbecomesprod).
A stack manifest can contain the following top-level sections:
# Optional: explicit stack name override
name: "plat-ue2-prod"
# Import other configurations
import:
- catalog/vpc/defaults
- mixins/region/us-east-2
- orgs/acme/plat/prod/_defaults
# Remote imports are supported, but they import stack config only:
# - github://acme/config/main/stacks/catalog/vpc.yaml
# Global-scope sections (apply to all components)
vars: {}
locals: {}
env: {}
settings: {}
hooks: {}
overrides: {}
# Component-type scope (apply to all components of that type)
terraform:
vars: {}
env: {}
settings: {}
hooks: {}
backend_type: s3
backend: {}
providers: {}
command: terraform
overrides: {}
helmfile:
vars: {}
env: {}
settings: {}
hooks: {}
command: helmfile
overrides: {}
# Component definitions
components:
terraform:
vpc:
metadata: {}
vars: {}
env: {}
settings: {}
hooks: {}
backend_type: s3
backend: {}
providers: {}
command: terraform
auth: {}
helmfile:
echo-server:
vars: {}
env: {}
settings: {}Variables passed as inputs to Terraform, Helmfile, or Packer components. Defined at global, component-type, or component level. Deep-merged across all levels with component-level values taking precedence.
vars:
environment: prod
region: us-east-1
tags:
Environment: Production
ManagedBy: AtmosMaps are recursively merged; lists are replaced (not appended).
File-scoped temporary variables for reducing repetition within a single YAML file. Locals do NOT inherit across file imports. They can reference each other using {{ .locals.name }} syntax with automatic dependency resolution.
locals:
namespace: acme
name_prefix: "{{ .locals.namespace }}-{{ .vars.stage }}"
components:
terraform:
vpc:
vars:
name: "{{ .locals.name_prefix }}-vpc"Locals can also access settings, vars, and env defined in the same file using {{ .settings.key }}, {{ .vars.key }}, and {{ .env.KEY }}.
Environment variables set when executing components. Simple key-value pairs merged shallowly across levels.
env:
AWS_PROFILE: acme-prod
TF_IN_AUTOMATION: "true"Integration metadata and configuration not passed to Terraform. Used for Atlantis, validation, and other Atmos integrations.
settings:
validation:
check-cidr:
schema_type: jsonschema
schema_path: schemas/vpc.json
dependencies:
components:
- component: vpc
- component: dns-zone
stack: plat-ue2-prod
- kind: file
path: configs/service.yamlComponent-only section that controls Atmos behavior for that component. Cannot be used at global or component-type level.
components:
terraform:
vpc:
metadata:
component: vpc # Terraform root module path
inherits:
- vpc/defaults # Inheritance chain
type: abstract # abstract or real (default)
enabled: true # Enable/disable component
locked: false # Prevent modifications
terraform_workspace: "custom-ws"
custom:
owner: platform-teamLifecycle event handlers that execute actions at specific points (e.g., after terraform apply).
hooks:
store-outputs:
events:
- after-terraform-apply
command: store
name: prod/ssm
outputs:
vpc_id: .vpc_idOverride the executable for a component type or specific component. Useful for OpenTofu, custom wrappers, or version-pinned binaries.
terraform:
command: tofuTerraform backend configuration. Atmos generates backend.tf.json automatically.
terraform:
backend_type: s3
backend:
s3:
bucket: acme-ue1-root-tfstate
region: us-east-1
encrypt: true
use_lockfile: trueTerraform provider configuration. Atmos generates providers_override.tf.json automatically.
terraform:
providers:
aws:
region: us-east-1
assume_role:
role_arn: "arn:aws:iam::{{ .vars.account_id }}:role/TerraformRole"Authentication configuration for cloud providers. Primarily defined in atmos.yaml but can be referenced at component level.
components:
terraform:
vpc:
auth:
identity: prod-adminScoped overrides that apply only to components defined in the current manifest and its imports (not to all components in the top-level stack). This is different from regular vars/env/settings which affect all components.
overrides:
env:
TEST_ENV_VAR: "overridden-value"
vars:
custom_tag: override
settings:
validation:
check-cidr:
schema_path: schemas/vpc-override.jsonAtmos deep-merges configuration from multiple levels. The precedence order (lowest to highest priority):
- Global scope (
vars:,env:,settings:) - Component-type scope (
terraform.vars:,helmfile.env:) - Base component defaults (via
metadata.inherits, in list order) - Component-level scope (
components.terraform.<name>.vars:) - Overrides (
overrides:,terraform.overrides:)
For maps, keys are recursively merged with higher-priority values overriding lower-priority ones. For lists, the entire list at higher priority replaces the lower-priority list (lists are not appended).
A common convention is to use _defaults.yaml files at each level of the directory hierarchy:
stacks/
orgs/
acme/
_defaults.yaml # Organization-wide defaults
plat/
_defaults.yaml # Tenant defaults
dev/
_defaults.yaml # Stage defaults
us-east-2.yaml # Top-level stack (deployable)
us-west-2.yaml
prod/
_defaults.yaml
us-east-2.yaml
us-west-2.yaml
The underscore prefix ensures these files sort to the top of directory listings. They are excluded from stack discovery via excluded_paths and must be explicitly imported. Atmos has no special handling for _defaults.yaml -- it is purely a naming convention.
Each level imports the parent _defaults.yaml and adds its own defaults:
# stacks/orgs/acme/plat/prod/_defaults.yaml
import:
- orgs/acme/plat/_defaults
vars:
stage: prod
tags:
Environment: ProductionUse atmos describe stacks to view the fully resolved configuration after all imports, inheritance, and overrides:
# View all stacks
atmos describe stacks
# Filter by stack
atmos describe stacks --stack plat-ue2-prod
# Filter by component and section
atmos describe stacks --components vpc --sections vars
# Output as JSON
atmos describe stacks --format json | jq '.["plat-ue2-prod"]'Use atmos describe component for a single component:
atmos describe component vpc -s plat-ue2-prodAtmos provides YAML functions for dynamic value resolution at runtime:
!terraform.output <component> <output>-- Read Terraform outputs from another component.!terraform.state <component> <path>-- Access Terraform state values.!store <store-name> <component> <key>-- Read from external key-value stores (SSM, Vault, etc.).!env <VAR_NAME>-- Read environment variables with optional defaults.!exec <command>-- Execute shell commands and use output.!include <path>-- Load content from external files.!secret <name>-- Resolve declared secrets.!appendand!unset-- Control inherited list/key merge behavior.
For the full current function inventory, load atmos-yaml-functions.
- Organize by org/tenant/stage/region: Structure stacks hierarchically so defaults cascade naturally through imports.
- Use catalog for component defaults: Place reusable component configurations in
stacks/catalog/and import them. - Keep inheritance shallow: Limit to 2-3 levels of
metadata.inheritsto maintain readability. - Use
_defaults.yamlat every level: Define shared vars, env, and settings at the appropriate organizational level. - Exclude non-deployable files: Configure
excluded_pathsto prevent catalog, mixin, and defaults files from being treated as top-level stacks. - Use
nameorname_templatefor stack naming: If legacyname_patternis present, migrate it. - Use
atmos describe stacksliberally: Always verify the resolved configuration before applying changes. - Treat remote imports as config only: use component
source:oratmos vendor pullwhen imported config references component code that is not already local.
- references/import-patterns.md -- Detailed import system: path resolution, remote imports, Go templates, context variables
- references/inheritance-deep-merge.md -- Deep-merge algorithm, component inheritance, override precedence