@@ -7,33 +7,62 @@ description: >-
77
88# Developing Stacks
99
10+ > ** Scope:** This skill is specific to the ** acme** infrastructure repository. It documents the
11+ > stack structure, naming conventions, and deployment patterns used here. For generic component development, see
12+ > ` developing-components ` .
13+
1014Guide for configuring Atmos stacks to deploy Terraform components across environments.
1115
1216## Stack Architecture Overview
1317
14- Stacks follow a hierarchical structure with inheritance at multiple levels :
18+ This repository uses a multi-tenant, multi-stage stack structure :
1519
1620```
1721stacks/
18- ├── orgs/acme/ # Organization root
19- │ ├── _defaults.yaml # Org-wide defaults (namespace, backend, account_map)
20- │ ├── plat/ # Platform tenant
21- │ │ ├── _defaults.yaml # Tenant defaults (tenant: plat)
22- │ │ ├── dev/ # Dev stage
23- │ │ │ ├── _defaults.yaml # Stage defaults + auth identity
24- │ │ │ └── us-east-2/ # Region
25- │ │ │ ├── foundation.yaml
26- │ │ │ ├── platform.yaml
27- │ │ │ └── app.yaml
28- ├── catalog/ # Component defaults library
22+ ├── orgs/acme/ # Organization root (namespace: acme)
23+ │ ├── _defaults.yaml # Org-wide defaults (namespace, backend, account_map)
24+ │ ├── core/ # Core tenant (shared infrastructure)
25+ │ │ ├── _defaults.yaml # Tenant defaults (tenant: core)
26+ │ │ ├── root/ # Root account stage
27+ │ │ │ ├── _defaults.yaml # Stage defaults + auth identity
28+ │ │ │ └── global-region/ # Global region (us-east-1)
29+ │ │ │ └── foundation.yaml
30+ │ │ ├── auto/ # Automation account
31+ │ │ ├── artifacts/ # Artifacts account (ECR, S3)
32+ │ │ ├── audit/ # Audit/logging account
33+ │ │ ├── dns/ # DNS account
34+ │ │ ├── network/ # Network account (TGW, VPN)
35+ │ │ └── security/ # Security account
36+ │ └── plat/ # Platform tenant (workloads)
37+ │ ├── _defaults.yaml # Tenant defaults (tenant: plat)
38+ │ ├── dev/ # Dev stage
39+ │ │ ├── _defaults.yaml # Stage defaults + auth identity
40+ │ │ ├── global-region/ # Global resources (IAM)
41+ │ │ │ └── foundation.yaml
42+ │ │ └── us-east-1/ # Primary region
43+ │ │ ├── foundation.yaml # VPC, networking
44+ │ │ ├── platform.yaml # ECS/EKS, databases
45+ │ │ └── app.yaml # Application resources
46+ │ ├── staging/ # Staging stage
47+ │ ├── prod/ # Production stage
48+ │ └── sandbox/ # Sandbox stage
49+ ├── catalog/ # Component defaults library
2950│ ├── vpc/defaults.yaml
3051│ ├── ecs/defaults.yaml
52+ │ ├── eks/cluster/defaults.yaml
3153│ └── ...
32- └── mixins/ # Reusable fragments
33- ├── region/us-east-2 .yaml
54+ └── mixins/ # Reusable fragments
55+ ├── region/us-east-1 .yaml
3456 └── stage/dev.yaml
3557```
3658
59+ ** Stack name format:** ` {namespace}-{tenant}-{region_short}-{stage} `
60+
61+ Examples for this repository:
62+ - ` acme-core-use1-root ` - Core root account in us-east-1
63+ - ` acme-plat-use1-dev ` - Platform dev in us-east-1
64+ - ` acme-plat-use1-prod ` - Platform prod in us-east-1
65+
3766## Core Patterns
3867
3968### 1. Catalog Defaults (Recommended Starting Point)
@@ -66,10 +95,10 @@ components:
6695Import the catalog and inherit from the abstract component in your target stack :
6796
6897` ` ` yaml
69- # stacks/orgs/acme/plat/dev/us-east-2 /foundation.yaml
98+ # stacks/orgs/acme/plat/dev/us-east-1 /foundation.yaml
7099import:
71100 - orgs/acme/plat/dev/_defaults
72- - mixins/region/us-east-2
101+ - mixins/region/us-east-1
73102 - catalog/vpc/defaults
74103
75104components:
@@ -80,7 +109,7 @@ components:
80109 inherits:
81110 - vpc/defaults # Inherits from the abstract component
82111 vars:
83- ipv4_primary_cidr_block: 10.0 .0.0/16 # Override for this environment
112+ ipv4_primary_cidr_block: 10.2 .0.0/16 # Dev environment CIDR
84113` ` `
85114
86115**Inheritance merging:**
@@ -146,7 +175,7 @@ terraform:
146175 backend_type: s3
147176 backend:
148177 s3:
149- bucket: acme-core-use2 -root-tfstate
178+ bucket: acme-core-use1 -root-tfstate
150179 # ...
151180
152181# stacks/orgs/acme/plat/_defaults.yaml (tenant level)
@@ -215,11 +244,11 @@ components:
215244# Validate the stack configuration
216245atmos validate stacks
217246
218- # See the resolved configuration
219- atmos describe component <component> -s <stack>
247+ # See the resolved configuration (example for dev)
248+ atmos describe component <component> -s acme-plat-use1-dev
220249
221250# Plan the deployment
222- atmos terraform plan <component> -s <stack>
251+ atmos terraform plan <component> -s acme-plat-use1-dev
223252` ` `
224253
225254# # Stack File Organization
@@ -236,6 +265,64 @@ Stack files are organized by layer:
236265
237266# # Common Patterns
238267
268+ # ## Catalog Organization for Multiple Purposes
269+
270+ When deploying multiple instances of the same component for different purposes, organize the catalog with abstract
271+ defaults and purpose-specific files that inherit from them :
272+
273+ ` ` `
274+ stacks/catalog/
275+ └── <component>/
276+ ├── defaults.yaml # Abstract base component (not deployed directly)
277+ └── <purpose>.yaml # Purpose-specific configuration
278+ ` ` `
279+
280+ **Abstract defaults file** (`stacks/catalog/<component>/defaults.yaml`):
281+
282+ ` ` ` yaml
283+ components:
284+ terraform:
285+ <component>/defaults:
286+ metadata:
287+ type: abstract # Not deployed directly
288+ component: <component> # Points to Terraform component
289+ vars:
290+ enabled: true
291+ # Organization-wide defaults for this component
292+ ` ` `
293+
294+ **Purpose-specific catalog file** (`stacks/catalog/<component>/<purpose>.yaml`):
295+
296+ ` ` ` yaml
297+ import:
298+ - catalog/<component>/defaults
299+
300+ components:
301+ terraform:
302+ <component>/<purpose>:
303+ metadata:
304+ component: <component> # Points to Terraform component
305+ inherits:
306+ - <component>/defaults # Inherits from abstract component
307+ vars:
308+ # Only include values that differ from defaults (keep it DRY)
309+ name: <purpose>-specific-name
310+ some_setting: override-value # Overrides default
311+ ` ` `
312+
313+ **Import in target stack:**
314+
315+ ` ` ` yaml
316+ import:
317+ - catalog/<component>/<purpose>
318+ ` ` `
319+
320+ **Deploy:**
321+
322+ ` ` ` bash
323+ atmos terraform plan <component>/<purpose> -s acme-plat-use1-dev
324+ ` ` `
325+
239326# ## Environment-Specific CIDR Blocks
240327
241328` ` ` yaml
@@ -248,23 +335,23 @@ components:
248335 vars:
249336 # No CIDR here - must be specified per environment
250337
251- # stacks/orgs/acme/plat/dev/us-east-2 /foundation.yaml
338+ # stacks/orgs/acme/plat/dev/us-east-1 /foundation.yaml
252339components:
253340 terraform:
254341 vpc:
255342 metadata:
256343 inherits: [vpc/defaults]
257344 vars:
258- ipv4_primary_cidr_block: 10.0 .0.0/16
345+ ipv4_primary_cidr_block: 10.2 .0.0/16
259346
260- # stacks/orgs/acme/plat/prod/us-east-2 /foundation.yaml
347+ # stacks/orgs/acme/plat/prod/us-east-1 /foundation.yaml
261348components:
262349 terraform:
263350 vpc:
264351 metadata:
265352 inherits: [vpc/defaults]
266353 vars:
267- ipv4_primary_cidr_block: 10.1 .0.0/16
354+ ipv4_primary_cidr_block: 10.0 .0.0/16
268355` ` `
269356
270357# ## Cross-Component Dependencies
@@ -314,10 +401,10 @@ components:
314401
315402` ` ` bash
316403# See fully resolved configuration
317- atmos describe component <component> -s <stack>
404+ atmos describe component <component> -s acme-plat-use1-dev
318405
319406# See all components in a stack
320- atmos describe stacks -s <stack>
407+ atmos describe stacks -s acme-plat-use1-dev
321408
322409# Validate all stacks
323410atmos validate stacks
0 commit comments