Implemented.
This PRD defines how Atmos resolves stack identity - the mechanism by which users reference stacks via the -s argument and how Atmos determines which stack configuration to use.
- Single Identity: Each stack has exactly ONE valid identifier
- Zero-Config: Newcomers can use stack filenames without any naming configuration
- Explicit Override: Advanced users can set a
namefield to control the identifier - Predictability: The identifier shown in
atmos list stacksis the only valid identifier
- Automatic migration of existing configurations
- Support for aliases or multiple valid names per stack
A stack's canonical identifier is determined by the following precedence (highest to lowest):
| Priority | Source | When Used |
|---|---|---|
| 1 | name field in manifest |
If set, this is the only valid identifier |
| 2 | name_template result |
If template is set (and no explicit name), template result is the identifier |
| 3 | name_pattern result |
If pattern is set (and no template/name), pattern result is the identifier |
| 4 | Filename | If nothing else is configured, filename is the identifier |
Key principle: There is no fallback. Only ONE identifier is valid per stack.
# stacks/legacy-prod.yaml
name: my-legacy-prod-stack
vars:
environment: prod
stage: ue1With name_template: "{{ .vars.environment }}-{{ .vars.stage }}" in atmos.yaml:
- Valid:
atmos tf plan vpc -s my-legacy-prod-stack - Invalid:
atmos tf plan vpc -s prod-ue1(template result ignored) - Invalid:
atmos tf plan vpc -s legacy-prod(filename ignored)
# stacks/legacy-prod.yaml
vars:
environment: prod
stage: ue1With name_template: "{{ .vars.environment }}-{{ .vars.stage }}":
- Valid:
atmos tf plan vpc -s prod-ue1 - Invalid:
atmos tf plan vpc -s legacy-prod
# stacks/deploy/prod/us-east-1.yaml
vars:
environment: prod
stage: ue1With name_pattern: "{environment}-{stage}":
- Valid:
atmos tf plan vpc -s prod-ue1 - Invalid:
atmos tf plan vpc -s deploy/prod/us-east-1
# stacks/prod.yaml
components:
terraform:
vpc:
vars:
cidr: "10.0.0.0/16"With no name, name_template, or name_pattern configured:
- Valid:
atmos tf plan vpc -s prod
This enables newcomers to start using Atmos immediately without configuring any naming strategy.
$ atmos terraform plan vpc -s my-explicit-stack
# Works as expectedWhen using an invalid identifier (e.g., filename when an explicit name is set), Atmos returns a helpful error with suggestions:
$ atmos terraform plan vpc -s legacy-prod
# Error
**Error:** invalid stack
## Explanation
Stack legacy-prod not found.
## Hints
💡 Did you mean my-legacy-prod-stack?
💡 Run atmos list stacks to see all available stacks.The error identifies the issue as an invalid stack (not component) and provides actionable hints.
The atmos list stacks command shows only canonical identifiers:
$ atmos list stacks
my-legacy-prod-stack # Not 'legacy-prod' or 'prod-ue1'
prod-ue1 # From template, not filename
dev # Filename (no naming config)In internal/exec/utils.go, the findComponentInStacks function determines the canonical name:
var canonicalStackName string
switch {
case stackManifestName != "":
// Priority 1: Explicit name from manifest
canonicalStackName = stackManifestName
case configAndStacksInfo.ContextPrefix != "" && configAndStacksInfo.ContextPrefix != stackName:
// Priority 2/3: Generated from name_template or name_pattern
canonicalStackName = configAndStacksInfo.ContextPrefix
default:
// Priority 4: Filename (zero-config)
canonicalStackName = stackName
}
stackMatches := configAndStacksInfo.Stack == canonicalStackNameIn internal/exec/utils.go, the processStackContextPrefix function enables filename-based identity:
switch {
case atmosConfig.Stacks.NameTemplate != "":
// Process name_template
case atmosConfig.Stacks.NamePattern != "":
// Process name_pattern
default:
// No naming config - use filename as identity
configAndStacksInfo.ContextPrefix = stackName
}The following test cases verify the single identity rule:
TestProcessStacks_RejectsGeneratedNameWhenExplicitNameSet: Using template-generated name fails when explicitnameis setTestProcessStacks_RejectsFilenameWhenExplicitNameSet: Using filename fails when explicitnameis setTestProcessStacks_RejectsFilenameWhenTemplateSet: Using filename fails whenname_templateis configuredTestProcessStacks_AcceptsFilenameWhenNoNamingConfigured: Using filename works when no naming is configuredTestDescribeStacks_FilenameAsKeyWhenNoNamingConfigured: DescribeStacks returns filename as key when no naming is configured
This is a behavioral change for users who:
- Have
namefield set but reference stacks by generated name or filename - Have
name_template/name_patternset but reference stacks by filename
Users will receive clear error messages indicating the stack was not found, prompting them to use the canonical identifier.
- Each stack has exactly ONE valid identifier
- Using any other identifier returns "stack not found"
atmos list stacksoutput matches the only valid identifier- All commands (terraform, helmfile, describe, etc.) respect this rule
- Newcomers can use filenames without any naming configuration
- PR: #1934
- Issue: #1932