Customize 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
-
stacks.base_pathspecifies the path to the folder where all Atmos stack config files (stack manifests) are defined. If the globalbase_pathis not provided or is an empty string,stacks.base_pathis an independent setting that supports both absolute and relative paths. If the globalbase_pathis defined,stacks.base_pathis relative to the globalbase_path -
stacks.included_pathstells Atmos where to search for the top-level stack manifestsnoteAtmos top-level stack manifests are configuration files that define all settings and components for the corresponding environment (organization, OU/tenant, account, region), and they are used in
atmosCLI commands likeatmos terraform plan <component> -s <top-level-stack>andatmos terraform apply <component> -s <top-level-stack> -
stacks.excluded_pathstells Atmos which paths fromstacks.included_pathsto exclude. For example, we will exclude the config files that don't contain the top-level stack manifests, but just define the default values that get imported into top-level stack manifestsnoteThe
_defaults.yamlnaming 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.yamlfiles themselves are not top-level Atmos stacks—they just contain default values to make the entire 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.infoThe
_defaults.yamlstack manifests are not imported into other Atmos manifests 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.yamlpattern in theexcluded_pathsconfiguration.See the _defaults.yaml Design Pattern for a complete explanation of this convention.
-
stacks.name_patternconfigures the name pattern for the top-level Atmos stacks using the context variablesnamespace,tenant,environmentandstageas the tokens. Depending on the structure of your organization, OUs, accounts and regions, setstacks.name_patternto the following:-
name_pattern: {stage}- if you use just one region and a few accounts (stages) in just one organization and one OU. In this case, the top-level Atmos stacks will use just thestage(account) in their names, and to provision the Atmos components in the top-level stacks, you will be executing Atmos commands likeatmos terraform apply <component> --stack dev,atmos terraform apply <component> --stack stagingandatmos terraform apply <component> --stack prod -
name_pattern: {environment}-{stage}- if you have multiple regions and accounts (stages) in just one organization and one OU. In this case, the top-level Atmos stacks will use theenvironment(region) andstage(account) in their names, and to provision the Atmos components in the top-level stacks, you will be executing Atmos commands likeatmos terraform apply <component> --stack ue2-dev,atmos terraform apply <component> --stack uw2-stagingandatmos terraform apply <component> --stack ue1-prod. Note that thename_patterncan also be defined as{stage}-{environment}, in which case the Atmos commands will look likeatmos terraform apply <component> --stack dev-ue2 -
name_pattern: {tenant}-{environment}-{stage}- if you have multiple regions, OUs (tenants) and accounts (stages) in just one organization. In this case, the top-level Atmos stacks will use thetenant,environment(region) andstage(account) in their names, and to provision the Atmos components in the top-level stacks, you will be executing Atmos commands likeatmos terraform apply <component> --stack plat-ue2-dev,atmos terraform apply <component> --stack core-uw2-stagingandatmos terraform apply <component> --stack plat-ue1-prod, whereplatandcoreare the OUs/tenants in your organization -
name_pattern: {namespace}-{tenant}-{environment}-{stage}- if you have a multi-org, multi-tenant, multi-account and multi-region architecture. In this case, the top-level Atmos stacks will use thenamespace,tenant,environment(region) andstage(account) in their names, and to provision the Atmos components in the top-level stacks, you will be executing Atmos commands likeatmos terraform apply <component> --stack org1-plat-ue2-dev,atmos terraform apply <component> --stack org2-core-uw2-stagingandatmos terraform apply <component> --stack org2-plat-ue1-prod, whereorg1andorg2are the organization names (defined asnamespacein the corresponding_defaults.yamlconfig files for the organizations)
-
-
stacks.name_templateserves the same purpose asstacks.name_pattern(defines the naming convention for the top-level Atmos stacks), but provides much more functionality. Instead of using the predefined context variables as tokens, it uses Go templates. Atmos Template Functions, Sprig Functions, Gomplate Functions, and Gomplate Datasources are supported as well-
For the
Gotemplate tokens, and you can use any Atmos sections (e.g.vars,providers,settings) that the Atmos commandatmos describe component <component> -s <stack>generates for a component in a stack. -
name_template: "{{.vars.tenant}}-{{.vars.environment}}-{{.vars.stage}}"defines the same name pattern for the top-level Atmos stacks asname_pattern: "{tenant}-{environment}-{stage}"does -
Since
stacks.name_templateallows using any variables form thevarssection (and other sections), you can define your own naming convention for your organization or for different clouds (AWS, Azure, GCP). For example, in the corresponding_defaults.yamlstack manifests, you can use the following variables:orginstead ofnamespacedivisioninstead oftenantregioninstead ofenvironmentaccountinstead ofstage
Then define the following
stacks.name_templateinatmos.yaml:atmos.yamlstacks:
name_template: "{{.vars.division}}-{{.vars.account}}-{{.vars.region}}"You will be able to execute all Atmos commands using the newly defined naming convention:
atmos terraform plan <component> -s <division-account-region>
atmos terraform apply <component> -s <division-account-region>
atmos describe component <component> -s <division-account-region>name_templatecan have complex logic and use template expressions and functions. The following template defines aname_templatethat builds astack_namestring by validating and concatenating several input variables in a hierarchical order.atmos.yaml
It pulls values from the Atmos section
varsand assigns them to local template variables:namespacetenantenvironmentstage
The template enforces hierarchical dependencies between variables:
namespaceis required- If
tenantis provided,namespacemust also be set - If
environmentis provided, bothtenantandnamespacemust be set - If
stageis provided, thenenvironment,tenant, andnamespacemust all be set
If validations pass, it constructs the
stack_nameprogressively:- Starts with
tenantif it exists - Appends
environmentif it exists - Appends
stageif it exists
The template outputs the resulting stack name. For example, if the variables are:
namespace: acme
tenant: plat
environment: ue2
stage: prodThe resulting stack name will be
plat-ue2-prod.
-
Use either stacks.name_pattern or stacks.name_template to define the naming convention for the top-level Atmos stacks.
stacks.name_template has higher priority.
If stacks.name_template is specified, stacks.name_pattern will be ignored.
Refer to Atmos Design Patterns for the examples on how to configure the stacks section in atmos.yaml for different use-cases