Stack Behavior
The stacks section of the atmos.yaml defines how Atmos locates and manages your stack configurations. Think of it as the bootstrapping configuration. Here you can define the stack name pattern or template used to build the "slugs" and specify where to find stack files.
Do not confuse this configuration with stack configuration.
This configuration below is defined in the atmos.yaml and instructs atmos where to find
your stack configurations.
atmos.yaml
Configuration Referenceโ
base_pathPath to the folder where all Atmos stack configuration files (stack manifests) are defined.
Environment variable:
ATMOS_STACKS_BASE_PATHCommand-line flags:--config-dir,--stacks-dirSupports both absolute and relative paths. If the global
base_pathis defined,stacks.base_pathis relative to it.included_pathsGlob patterns specifying where to search for top-level stack manifests.
Environment variable:
ATMOS_STACKS_INCLUDED_PATHS(comma-separated)Top-level stack manifests are configuration files that define all settings and components for a corresponding environment (organization, OU/tenant, account, region). They are used in CLI commands like
atmos terraform plan <component> -s <stack>.Example:
included_paths:
- "orgs/**/*"excluded_pathsGlob patterns specifying which paths from
included_pathsto exclude from stack discovery.Environment variable:
ATMOS_STACKS_EXCLUDED_PATHS(comma-separated)Commonly used to exclude
_defaults.yamlfiles which contain default values but are not top-level stacks themselves.Example:
excluded_paths:
- "**/_defaults.yaml"name_template(Recommended) Defines the naming convention using Go templates. This is the preferred approach as it provides more flexibility and uses your actual variable names.
Environment variable:
ATMOS_STACKS_NAME_TEMPLATESupports Go templates, Atmos Template Functions, Sprig Functions, Gomplate Functions, and Gomplate Datasources.
You can use any Atmos sections (e.g.,
vars,providers,settings) thatatmos describe componentgenerates.Example:
name_template: "{{.vars.tenant}}-{{.vars.environment}}-{{.vars.stage}}"name_patternDefines the naming convention using predefined context tokens. Consider using
name_templateinstead for more flexibility.Environment variable:
ATMOS_STACKS_NAME_PATTERNAvailable tokens:
{namespace},{tenant},{environment},{stage}Example:
name_pattern: "{tenant}-{environment}-{stage}"inheritControls what sections are inherited when components use
metadata.inherits.See: Inheritance Behavior for complete documentation.
Example:
stacks:
inherit:
metadata: true # Enable metadata inheritance (default)
The _defaults.yaml Conventionโ
The _defaults.yaml naming convention is the recommended way to define stack manifests with default configurations for organizations, OUs/tenants, accounts, and regions.
This is a naming convention, not an Atmos feature. The _defaults.yaml files are not top-level Atmos stacksโthey contain default values to make configuration reusable and DRY. The underscore prefix ensures these files sort to the top of directory listings and are visually distinct from actual stack configurations.
The _defaults.yaml stack manifests are not imported automatically. You must explicitly import them using imports. Atmos has no special knowledge of this naming patternโthese files are only excluded from stack discovery because they match the **/_defaults.yaml pattern in excluded_paths.
See the _defaults.yaml Design Pattern for a complete explanation.
Stack Naming with name_template (Recommended)โ
Use name_template to define your stack naming convention. This approach references your actual vars and provides more flexibility than name_pattern.
name_template over name_patternWhile name_pattern uses predefined tokens like {tenant}, name_template references your actual variables like {{.vars.tenant}}. This makes your configuration more explicit and allows for custom variable names, validation logic, and complex transformations.
Common Patternsโ
Choose a pattern based on your organizational structure:
stacks:
name_template: "{{.vars.stage}}"
# Results: dev, staging, prod
stacks:
name_template: "{{.vars.environment}}-{{.vars.stage}}"
# Results: ue2-dev, uw2-staging, ue1-prod
stacks:
name_template: "{{.vars.tenant}}-{{.vars.environment}}-{{.vars.stage}}"
# Results: plat-ue2-dev, core-uw2-prod
stacks:
name_template: "{{.vars.namespace}}-{{.vars.tenant}}-{{.vars.environment}}-{{.vars.stage}}"
# Results: org1-plat-ue2-dev, org2-core-uw2-prod
Custom Variable Namesโ
Use name_template to define your own naming convention with custom variables. For example, to use division, account, and region instead of the standard names:
stacks:
name_template: "{{.vars.division}}-{{.vars.account}}-{{.vars.region}}"
Commands: atmos terraform apply vpc -s <division-account-region>
Advanced Template with Validationโ
name_template supports complex logic with template expressions and functions:
atmos.yaml
This template:
- Enforces hierarchical dependencies (
stagerequiresenvironment, which requirestenant, which requiresnamespace) - Constructs the stack name progressively from available variables
- For variables
namespace: acme,tenant: plat,environment: ue2,stage: prod, outputsplat-ue2-prod
Using name_pattern (Legacy)โ
name_templatename_pattern uses predefined tokens that map to specific variable names. We recommend using name_template instead, which references your actual variables and provides more flexibility. If both are specified, name_template takes precedence.
The name_pattern option uses predefined tokens:
| Token | Maps to Variable |
|---|---|
{namespace} | vars.namespace |
{tenant} | vars.tenant |
{environment} | vars.environment |
{stage} | vars.stage |
stacks:
name_pattern: "{tenant}-{environment}-{stage}"
This is equivalent to:
stacks:
name_template: "{{.vars.tenant}}-{{.vars.environment}}-{{.vars.stage}}"
Refer to Atmos Design Patterns for examples on configuring the stacks section for different use-cases.
Stack Configuration Optionsโ
๐๏ธ Inheritance Behavior
Configure what sections are inherited
Related Commandsโ
๐๏ธ atmos list stacks
List all stacks in the project
๐๏ธ atmos describe stacks
Describe stacks and their components
๐๏ธ atmos describe affected
Show stacks affected by changes
๐๏ธ atmos validate stacks
Validate stack configurations
๐๏ธ Inheritance Guide
Learn about component inheritance