Skip to content

Commit 6ac3d15

Browse files
♻️ docs: update Claude skills with improved vendoring docs and catalog patterns (#836)
2 parents 70a09d2 + 63e8360 commit 6ac3d15

File tree

3 files changed

+172
-31
lines changed

3 files changed

+172
-31
lines changed

examples/snippets/.claude/skills/developing-components/SKILL.md

Lines changed: 57 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,20 @@ description:
77

88
# Developing Components
99

10+
> **Scope:** This skill is generic and applies to any Cloud Posse reference architecture project. It covers patterns for
11+
> vendoring and creating Terraform components that are consistent across all customers.
12+
1013
Components are opinionated Terraform root modules that implement a specific AWS resource with predefined conventions.
1114

1215
## Before Creating a New Component
1316

1417
**Always check for existing components first.** Creating new components adds maintenance burden.
1518

16-
### 1. Check Local Generic Components
19+
### 1. Check Local Components
20+
21+
```bash
22+
ls components/terraform/
23+
```
1724

1825
Many use cases can be solved by configuring existing generic components via catalog:
1926

@@ -29,12 +36,58 @@ Browse https://docs.cloudposse.com/components/library/ for pre-built components.
2936
- `aurora-postgres`, `rds` - Databases
3037
- `elasticache-redis` - Caching
3138
- `ecs`, `ecs-service` - Container workloads
32-
- `cloudwatch-logs`, `sns-topic`, `sqs-queue` - AWS services
39+
- `s3-bucket`, `dynamodb`, `sqs-queue` - Storage and messaging
40+
- `cloudwatch-logs`, `sns-topic` - Monitoring and notifications
41+
42+
#### Cloud Posse Component Sources
43+
44+
| Resource | Location |
45+
| ---------------------- | ---------------------------------------------------------- |
46+
| Component Library Docs | https://docs.cloudposse.com/components/library/ |
47+
| Component Repositories | `github.com/cloudposse-terraform-components/aws-<service>` |
48+
| Mixins Repository | `github.com/cloudposse-terraform-components/mixins` |
49+
50+
**Find latest version:**
51+
52+
```bash
53+
gh release view --repo cloudposse-terraform-components/aws-<component> --json tagName
54+
```
55+
56+
#### Vendoring a Cloud Posse Component
57+
58+
1. Create the component directory and `component.yaml`:
59+
60+
```bash
61+
mkdir -p components/terraform/<component-name>
62+
```
63+
64+
2. Create `components/terraform/<component-name>/component.yaml`:
65+
66+
<!-- prettier-ignore-start -->
67+
68+
```yaml
69+
apiVersion: atmos/v1
70+
kind: ComponentVendorConfig
71+
spec:
72+
source:
73+
uri: github.com/cloudposse-terraform-components/aws-<component>.git//src?ref={{ .Version }}
74+
version: <latest-version> # Use gh release view to find this
75+
included_paths:
76+
- "**/**"
77+
excluded_paths:
78+
- "providers.tf"
79+
mixins:
80+
# Use provider mixin without account-map dependency (for single-account deployments)
81+
- uri: https://raw.githubusercontent.com/cloudposse-terraform-components/mixins/{{ .Version }}/src/mixins/provider-without-account-map.tf
82+
version: v0.3.2
83+
filename: providers.tf
84+
```
85+
86+
<!-- prettier-ignore-end -->
3387
34-
To vendor a Cloud Posse component:
88+
3. Pull the component:
3589
3690
```bash
37-
# Add to component.yaml in the component directory, then:
3891
atmos vendor pull -c <component-name>
3992
```
4093

examples/snippets/.claude/skills/developing-stacks/SKILL.md

Lines changed: 114 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
1014
Guide 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
```
1721
stacks/
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:
6695
Import 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
7099
import:
71100
- orgs/acme/plat/dev/_defaults
72-
- mixins/region/us-east-2
101+
- mixins/region/us-east-1
73102
- catalog/vpc/defaults
74103
75104
components:
@@ -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
216245
atmos 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
252339
components:
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
261348
components:
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
323410
atmos validate stacks

examples/snippets/CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ atmos terraform clean <component> -s <stack> # Destroys local .terraform and
7272
## Important Notes
7373

7474
- Uses **OpenTofu** (not Terraform) - `command: "tofu"` in atmos.yaml
75+
- **Never run `tofu init` or `terraform init` directly** in component directories. Atmos handles initialization automatically when running `atmos terraform plan/apply`.
7576
- Prefer `!terraform.state` in stack YAML over `remote-state.tf` files
7677
- Prefer existing generic components (`iam-role`, `s3-bucket`, `lambda`) over creating new ones
7778
- Set `account_map_enabled: false` - uses static `account_map` variable, not account-map component

0 commit comments

Comments
 (0)