Multi-Region Configuration
The Multi-Region Configuration pattern describes how to deploy the same infrastructure across multiple AWS regions. This pattern is the foundation for understanding how Atmos handles variation across different dimensions.
Use-casesβ
Use the Multi-Region Configuration pattern when:
-
You need to deploy infrastructure to multiple AWS regions for disaster recovery (DR)
-
You want to reduce latency by deploying closer to your users
-
You have compliance requirements that mandate data residency in specific regions
-
You need to provision region-specific resources while sharing common configuration
Benefitsβ
The Multi-Region Configuration pattern provides the following benefits:
-
Region-specific configuration is defined once and reused across all stacks in that region
-
Adding a new region requires minimal changesβjust create a new stack file
-
Common component configuration is shared, keeping your infrastructure DRY
-
Each region can have unique settings (CIDR blocks, availability zones, etc.) while inheriting shared defaults
How It Worksβ
Each region has its own top-level stack file that imports shared component defaults and specifies region-specific settings.
Exampleβ
The following example shows how to deploy vpc and vpc-flow-logs-bucket components across two regions: us-east-2 and us-west-2.
Directory Structureβ
β # Centralized stacks configuration
βββ stacks
β βββ catalog # component-specific defaults
β β βββ vpc-flow-logs-bucket
β β β βββ defaults.yaml
β β βββ vpc
β β βββ defaults.yaml
β βββ deploy # top-level stacks
β βββ dev
β βββ us-east-2.yaml
β βββ us-west-2.yaml
β
β # Centralized components configuration
βββ components
βββ terraform
βββ vpc
βββ vpc-flow-logs-bucket
Configure atmos.yamlβ
Add the following configuration to atmos.yaml:
atmos.yaml
Configure Component Catalogβ
Define default configuration for each component in the catalog:
stacks/catalog/vpc-flow-logs-bucket/defaults.yaml
stacks/catalog/vpc/defaults.yaml
Configure Top-Level Stack Manifestsβ
Each region's stack file imports the shared defaults and specifies region-specific configuration:
stacks/deploy/dev/us-east-2.yaml
stacks/deploy/dev/us-west-2.yaml
The environment variable is typically set to an abbreviation of the region (e.g., ue2 for us-east-2, uw2 for us-west-2). This makes stack names shorter and more readable: ue2-dev instead of us-east-2-dev.
Provision the Componentsβ
Deploy to both regions:
# Deploy to us-east-2
atmos terraform apply vpc-flow-logs-bucket -s ue2-dev
atmos terraform apply vpc -s ue2-dev
# Deploy to us-west-2
atmos terraform apply vpc-flow-logs-bucket -s uw2-dev
atmos terraform apply vpc -s uw2-dev
Adding a New Regionβ
To add a new region (e.g., eu-west-1):
stacks/deploy/dev/eu-west-1.yaml
Then deploy:
atmos terraform apply vpc-flow-logs-bucket -s ew1-dev
atmos terraform apply vpc -s ew1-dev
Reducing Duplication with Mixinsβ
As your multi-region deployment grows, you may notice duplication across region stack files (e.g., the same region, environment, and availability_zones repeated). You can extract this into Mixins to keep your configuration DRY.
For example, create a region mixin:
stacks/mixins/region/us-east-2.yaml
Then your stack file becomes simpler:
stacks/deploy/dev/us-east-2.yaml
See Mixins for more details on this approach.
Related Patternsβ
- Organizational Hierarchy Configuration - Extend this pattern with multiple organizations, tenants, and accounts
- Component Catalog - Organize reusable component defaults
- Layered Stack Configuration - Group components into functional layers