Skip to content

Commit 5ab4142

Browse files
committed
fix: update readme with accurate features and clearer structure
1 parent 46bee08 commit 5ab4142

1 file changed

Lines changed: 167 additions & 72 deletions

File tree

README.md

Lines changed: 167 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,175 @@
11
# CDKO - Multi-Account & Multi-Region CDK Orchestrator
22

3-
CDKO eliminates the pain of deploying AWS CDK infrastructure across multiple accounts and regions. Deploy once, everywhere - with full CDK compatibility and intelligent stack mapping.
3+
CDKO is a lightweight orchestrator that eliminates the pain of deploying AWS CDK stacks across multiple accounts and regions. Deploy once, everywhere - with full CDK compatibility and intelligent stack mapping.
44

5-
## Features
5+
## The Problem
66

7-
- **Multi-account & multi-region deployment** - Deploy across account-region matrices in parallel or sequentially
8-
- **Smart stack detection** - Automatically discovers and maps CDK stack construct IDs to accounts/regions
9-
- **Profile pattern matching** - Support for wildcards (`dev-*`) and comma-separated lists (`dev,staging,prod`)
10-
- **Cloud assembly caching** - Synthesizes once per profile, deploys many times for optimal performance
11-
- **Flexible stack targeting** - Deploy specific stacks using pattern matching or wildcards
12-
- **Multiple deployment modes** - Support for diff, changeset, and execute operations
13-
- **Safe defaults** - Creates changesets for review before execution
7+
If you've ever tried deploying CDK stacks across multiple AWS accounts and regions, you know the pain - running `cdk deploy` over and over, changing profiles and regions manually. You end up writing fragile shell scripts that loop through environments, or worse, doing it all by hand.
8+
9+
CDKO solves this with a simple command:
10+
11+
```bash
12+
# Deploy to 6 locations (2 accounts × 3 regions) in parallel
13+
cdko -p "dev,prod" -s MyStack -r us-east-1,eu-west-1,ap-southeast-1
14+
```
1415

1516
## Installation
1617

1718
```bash
1819
npm install -g @owloops/cdko
1920
```
2021

21-
**Prerequisites**: Node.js 18+, AWS CDK, AWS CLI configured
22+
**Prerequisites**: Node.js 18+, AWS CDK, AWS CLI configured with your profiles
2223

2324
## Quick Start
2425

2526
```bash
26-
# Initialize configuration
27+
# Navigate to your CDK project
28+
cd my-cdk-app
29+
30+
# Auto-detect your stacks and create configuration
2731
cdko init
2832

29-
# Deploy stack across accounts and regions
30-
cdko -p "dev,prod" -s MyStack -r us-east-1,eu-west-1
33+
# Deploy a stack across multiple regions
34+
cdko -p MyProfile -s MyStack -r us-east-1,eu-west-1
3135

32-
# Preview changes
36+
# Preview changes first
3337
cdko -p MyProfile -s MyStack -m diff
3438
```
3539

36-
## CLI Options
40+
## How CDKO Works
41+
42+
CDKO handles three common CDK deployment patterns:
43+
44+
### 1. Environment-Agnostic Stacks
45+
46+
Keep a single stack definition and deploy to any regions you specify:
47+
48+
```typescript
49+
new MyStack(app, 'MyStack');
50+
```
51+
52+
```bash
53+
cdko -p MyProfile -s MyStack -r us-east-1,eu-west-1,ap-southeast-1
54+
```
55+
56+
### 2. Environment-Specific Stacks
57+
58+
When you've already specified account and/or region in your stack:
59+
60+
```typescript
61+
new MyStack(app, 'MyStack-Dev', { env: { account: '123456789012', region: 'us-east-1' }})
62+
new MyStack(app, 'MyStack-Staging', { env: { region: 'us-west-2' }})
63+
```
64+
65+
CDKO detects these automatically and deploys to the correct environments.
66+
67+
### 3. Different Construct IDs, Same Stack Name
68+
69+
Common for multi-region deployments where the stack name is consistent but construct IDs differ:
70+
71+
```typescript
72+
new MyStack(app, 'MyStack-US', { stackName: 'MyStack', env: { region: 'us-east-1' }})
73+
new MyStack(app, 'MyStack-EU', { stackName: 'MyStack', env: { region: 'eu-west-1' }})
74+
new MyStack(app, 'MyStack-AP', { stackName: 'MyStack', env: { region: 'ap-southeast-1' }})
75+
```
76+
77+
CDKO understands these are all the same logical stack.
78+
79+
## Pattern Matching
80+
81+
Pattern matching makes CDKO powerful for complex deployments:
82+
83+
```bash
84+
# Deploy all stacks matching a pattern
85+
cdko -p MyProfile -s "API*" -r us-east-1,us-west-2
86+
87+
# Deploy across multiple accounts using profile patterns
88+
cdko -p "dev-*,prod-*" -s MyStack -r all
89+
90+
# Mix and match patterns
91+
cdko -p "dev,staging,prod" -s "Frontend*,Backend*" -r us-east-1,eu-west-1
92+
```
93+
94+
## CLI Reference
95+
96+
```bash
97+
cdko [options]
98+
```
99+
100+
### Required Options
101+
102+
| Option | Description |
103+
|--------|-------------|
104+
| `-p, --profile` | AWS profile(s) - supports patterns (`dev-*`), lists (`dev,prod`), and wildcards |
105+
| `-s, --stack` | Stack name pattern to deploy - supports wildcards (`API*`) |
106+
107+
### Optional Flags
37108

38109
| Option | Description | Default |
39110
|--------|-------------|---------|
40-
| `-p, --profile` | AWS profile to use (supports patterns: `dev-*`, comma-separated: `dev,prod`) | *Required* |
41-
| `-s, --stack` | Stack name pattern to deploy | *Required* |
42111
| `-r, --region` | Comma-separated regions or 'all' | `us-east-1` |
43112
| `-m, --mode` | Deployment mode: `diff`, `changeset`, `execute` | `changeset` |
44113
| `-x, --sequential` | Deploy regions sequentially instead of parallel | `false` |
45114
| `-d, --dry-run` | Show what would be deployed without executing | `false` |
46115
| `-v, --verbose` | Enable verbose CDK output | `false` |
47-
| `--include-deps` | Include dependency stacks when deploying | `false` |
116+
| `--include-deps` | Include dependency stacks (removes --exclusively flag) | `false` |
48117
| `--parameters` | CDK parameters (KEY=VALUE or STACK:KEY=VALUE) | - |
49118
| `--context` | CDK context values (KEY=VALUE) | - |
50-
| `--cdk-opts` | Pass options directly to CDK commands | - |
119+
| `--cdk-opts` | Pass additional options directly to CDK | - |
51120
| `-h, --help` | Show help message | - |
52-
| `--version` | Show version number | - |
121+
| `--version` | Show version with build info | - |
122+
123+
### Deployment Modes
124+
125+
- **diff**: Shows what changes would be made without executing
126+
- **changeset**: Creates CloudFormation changesets for review (default)
127+
- **execute**: Deploys immediately with automatic changeset execution
53128

54-
## Examples
129+
### Examples
55130

56131
```bash
57-
# Multi-account + multi-region
58-
cdko -p "dev,staging,prod" -s MyApp -r us-east-1,eu-west-1
132+
# Preview changes across all regions
133+
cdko -p prod -s MyStack -r all -m diff
134+
135+
# Deploy with parameters
136+
cdko -p dev -s MyStack --parameters BucketName=my-bucket
137+
138+
# Stack-specific parameters
139+
cdko -p dev -s MyStack --parameters MyStack:KeyName=my-key
59140

60-
# Pattern matching
61-
cdko -p "dev-*" -s "Production-*"
141+
# Deploy multiple stacks to multiple accounts
142+
cdko -p "dev-*,staging-*" -s "API*,Frontend*" -r us-east-1,eu-west-1
62143

63-
# With parameters
64-
cdko -p MyProfile -s MyApp --parameters KeyName=my-key
144+
# Execute immediately (skip changeset review)
145+
cdko -p prod -s MyStack -m execute
65146

66-
# Execute mode (skip changeset review)
67-
cdko -p MyProfile -s MyApp -m execute
147+
# Dry run to see deployment plan
148+
cdko -p "dev-*" -s "Production-*" -d
149+
150+
# Pass CDK options
151+
cdko -p dev -s MyStack --cdk-opts "--require-approval never"
152+
153+
# Sequential deployment
154+
cdko -p prod -s CriticalStack -r us-east-1,us-west-2 -x
68155
```
69156

70157
## Configuration
71158

72-
Run `cdko init` to auto-detect your CDK stacks and create a `.cdko.json` configuration:
159+
CDKO uses a `.cdko.json` file to map your logical stacks to their CDK construct IDs. Run `cdko init` to auto-generate this from your existing CDK app:
73160

74161
```json
75162
{
76163
"version": "0.1",
77164
"stackGroups": {
78-
"Production-MyApp": {
165+
"MyStack": {
79166
"123456789012/us-east-1": {
80-
"constructId": "Production-MyApp",
167+
"constructId": "MyStack",
81168
"account": "123456789012",
82169
"region": "us-east-1"
83170
},
84171
"123456789012/eu-west-1": {
85-
"constructId": "Production-MyApp-EU",
172+
"constructId": "MyStack-EU",
86173
"account": "123456789012",
87174
"region": "eu-west-1"
88175
}
@@ -93,29 +180,64 @@ Run `cdko init` to auto-detect your CDK stacks and create a `.cdko.json` configu
93180
}
94181
```
95182

96-
### Stack Mapping
183+
### Understanding Stack Mapping
97184

98-
CDK creates different **construct IDs** for the same logical stack across environments:
185+
CDK creates different construct IDs for the same logical stack across environments. For example:
99186

100187
- Construct ID: `Development-MyApp` → Stack name: `MyApp` (dev account)
101188
- Construct ID: `Production-MyApp` → Stack name: `MyApp` (prod account)
102189
- Construct ID: `MyApp-EU` → Stack name: `MyApp` (EU region)
103190

104-
CDKO's `.cdko.json` automatically maps your patterns (`*MyApp`) to the correct construct IDs per account/region.
191+
CDKO's configuration automatically maps your patterns (like `*MyApp`) to the correct construct IDs per account/region combination.
105192

106193
## Environment Variables
107194

108-
- `CDK_TIMEOUT` - Timeout for CDK operations (default: "not set")
195+
- `CDK_TIMEOUT` - Timeout for CDK operations (default: not set)
109196
- `CDK_CLI_NOTICES` - Set to "true" to show CDK notices (default: hidden)
110-
- `DEBUG` - Enable detailed error traces for troubleshooting
197+
- `DEBUG` - Set to "1" for detailed error traces
198+
199+
## When to Use CDKO
200+
201+
CDKO is designed for deploying infrastructure and stateful resources from your local machine. It's particularly useful for:
202+
203+
- Initial infrastructure setup across multiple accounts
204+
- Deploying foundational resources (VPCs, databases, etc.)
205+
- Testing infrastructure changes across environments
206+
- Managing resources that don't fit well in CI/CD pipelines
207+
208+
For application deployments and automated workflows, use your CI/CD pipeline. CDKO and CI/CD complement each other - you can even call CDKO from within your pipeline for infrastructure updates.
209+
210+
## Comparison to Similar Tools
211+
212+
If you're familiar with Terraform, CDKO is similar to Terragrunt - it's an orchestration layer that makes it practical to deploy infrastructure at scale across complex multi-account, multi-region environments. Just as Terragrunt wraps Terraform to solve the multi-environment deployment problem, CDKO wraps CDK to provide the same capability.
111213

112214
## Troubleshooting
113215

114-
- **AWS Authentication**: If credentials expire, run `aws sso login --profile <profile>`
115-
- **Multi-Account Issues**: Ensure all profiles have valid credentials and required permissions
116-
- **Profile Patterns**: Use quotes around patterns: `cdko -p "dev-*"` not `cdko -p dev-*`
117-
- **Graceful Shutdown**: Ctrl+C cancels all pending operations cleanly
118-
- **Clear Errors**: CDK errors are parsed and displayed with context
216+
### AWS Authentication
217+
218+
If credentials expire during deployment:
219+
220+
```bash
221+
aws sso login --profile dev
222+
aws sso login --profile prod
223+
```
224+
225+
### Profile Patterns
226+
227+
Always quote patterns to prevent shell expansion:
228+
229+
```bash
230+
cdko -p "dev-*" # Correct
231+
cdko -p dev-* # Shell will expand this
232+
```
233+
234+
### Debug Mode
235+
236+
See detailed execution information:
237+
238+
```bash
239+
DEBUG=1 cdko -p dev -s MyStack -v
240+
```
119241

120242
## Development
121243

@@ -131,38 +253,11 @@ npm run lint
131253

132254
# Run tests
133255
npm test
134-
135-
# Test in any CDK project
136-
cdko --help
137256
```
138257

139258
## Testing
140259

141-
CDKO includes comprehensive integration tests that verify core functionality against real CDK stacks.
142-
143-
### Test Structure
144-
145-
The `test/` directory contains a complete CDK project used as a test fixture:
146-
147-
```text
148-
test/
149-
├── test/ # Jest tests
150-
│ ├── cdko-integration.test.ts # CDKO CLI integration tests
151-
│ └── cdko-test-patterns.test.ts # CDK construct tests
152-
├── cdk.out/ # Pre-synthesized CDK stacks
153-
├── package.json # CDK project dependencies
154-
└── jest.config.js # Jest configuration
155-
```
156-
157-
### Test Coverage
158-
159-
- **Pattern matching** - Wildcard stack selection (`Production-*`)
160-
- **Multi-region deployment** - Cross-region deployment planning
161-
- **Configuration generation** - `cdko init` command testing
162-
- **Error handling** - Invalid patterns and missing parameters
163-
- **CLI commands** - Help, version, and parameter validation
164-
165-
### Running Tests
260+
The test suite includes comprehensive integration tests against real CDK stacks:
166261

167262
```bash
168263
# Run all tests
@@ -172,7 +267,7 @@ npm test
172267
cd test && npm test -- --testNamePattern="CDKO"
173268
```
174269

175-
All tests use the `--dry-run` flag to prevent actual AWS deployments, making them safe to run in any environment.
270+
All tests use the `--dry-run` flag to prevent actual AWS deployments.
176271

177272
## Acknowledgments
178273

0 commit comments

Comments
 (0)