Layered Stack Configuration
The Layered Stack Configuration pattern organizes components into infrastructure layers based on their functionβsimilar to how network architectures have distinct layers (network, transport, application). Each layer groups related components and can be managed independently.
Use-casesβ
Use the Layered Stack Configuration pattern when:
-
You have many components that naturally group by function (networking, data, compute, etc.)
-
Different teams own different layers of infrastructure
-
You want to import only the layers needed for a specific environment
Benefitsβ
The Layered Stack Configuration pattern provides the following benefits:
-
Components are organized by their infrastructure function, making configs intuitive to navigate
-
Teams can own specific layers using tools like GitHub's
CODEOWNERS -
Stacks can import only the layers they need (e.g., a dev environment might skip the monitoring layer)
-
Changes to one layer don't affect other layers
Exampleβ
The following example organizes infrastructure into three layers: network, data, and compute.
Directory Structureβ
βββ stacks
β βββ catalog # component defaults
β β βββ vpc
β β β βββ defaults.yaml
β β βββ rds
β β β βββ defaults.yaml
β β βββ eks
β β βββ defaults.yaml
β βββ layers # infrastructure layers
β β βββ network.yaml
β β βββ data.yaml
β β βββ compute.yaml
β βββ deploy
β βββ dev.yaml
β βββ prod.yaml
β
βββ components
βββ terraform
βββ vpc
βββ rds
βββ eks
Configure atmos.yamlβ
atmos.yaml
Define the Layersβ
Each layer imports the component defaults for that infrastructure function:
stacks/layers/network.yaml
stacks/layers/data.yaml
stacks/layers/compute.yaml
Import Layers into Stacksβ
Stacks import the layers they need:
stacks/deploy/dev.yaml
stacks/deploy/prod.yaml
Common Layer Examplesβ
Here are typical infrastructure layers you might define:
| Layer | Components | Purpose |
|---|---|---|
network | VPC, subnets, NAT, VPN | Foundation networking |
security | WAF, security groups, KMS | Security controls |
data | RDS, ElastiCache, S3 | Data storage |
compute | EKS, ECS, EC2 | Application runtime |
observability | CloudWatch, Datadog | Monitoring and logging |
Selective Layer Importβ
Not every environment needs every layer. For example, a minimal dev environment might skip observability:
stacks/deploy/dev.yaml
While production includes everything:
stacks/deploy/prod.yaml
Layer Dependenciesβ
Layers often have implicit dependencies. The compute layer depends on the network layer being provisioned first. Document or enforce this ordering in your deployment process:
# Deploy in layer order
atmos terraform apply vpc -s prod
atmos terraform apply rds -s prod
atmos terraform apply eks -s prod
Related Patternsβ
- Component Catalog - Define component defaults imported by layers
- Mixins - Reusable configuration fragments
- Component Overrides - Apply overrides to all components in a layer