Skip to content

Commit 5e69a10

Browse files
committed
docs: update docs
1 parent 5738ca4 commit 5e69a10

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

docs/ami-local-development.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
This guide explains how to use `pg-ami-builder` for local AMI development and iteration.
44

5+
Summary
6+
7+
| Aspect | CI/CD Workflows | pg-ami-builder |
8+
|--------------------|---------------------------------|-----------------------------------------|
9+
| AMI Creation | Packer auto-creates only | Packer auto-creates + manual create-ami |
10+
| Workflow | Linear, automated | Iterative, debuggable |
11+
| State | Stateless, ephemeral | Stateful, persistent |
12+
| Error Handling | Terminate and restart | Preserve, debug, fix, continue |
13+
| Use Case | Production releases, CI testing | Local development, iteration |
14+
| Instance Lifecycle | Always terminated | Preserved for debugging |
15+
16+
517
## Prerequisites
618

719
### Required Tools
@@ -36,25 +48,25 @@ Your AWS user/role needs these permissions:
3648

3749
```bash
3850
# Run phase 1 build (launches instance and runs packer build)
39-
aws-vault exec dev -- nix run .#pg-ami-builder -- build phase1 --postgres-version 15
51+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- build phase1 --postgres-version 15
4052

4153
# If packer build fails, instance stays alive for debugging
4254
# SSH to investigate
43-
aws-vault exec dev -- nix run .#pg-ami-builder -- ssh
55+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- ssh
4456

4557
# Make local changes and re-run with file sync
4658
vim ansible/playbook.yml
47-
aws-vault exec dev -- nix run .#pg-ami-builder -- ansible-rerun phase1 --sync-files
59+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- ansible-rerun phase1 --sync-files
4860

4961
# Cleanup when done
50-
aws-vault exec dev -- nix run .#pg-ami-builder -- cleanup
62+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- cleanup
5163
```
5264

5365
### Building Phase 2
5466

5567
```bash
5668
# Run phase 2 with existing stage-1 AMI
57-
aws-vault exec dev -- nix run .#pg-ami-builder -- build phase2 \
69+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- build phase2 \
5870
--source-ami ami-stage1-xyz \
5971
--postgres-version 15
6072
```
@@ -161,40 +173,40 @@ nix run .#pg-ami-builder -- cleanup [flags]
161173

162174
```bash
163175
# Run phase 1 build (launches instance and runs packer build)
164-
aws-vault exec dev -- nix run .#pg-ami-builder -- build phase1 --postgres-version 15
176+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- build phase1 --postgres-version 15
165177

166178
# If packer fails, instance stays up for debugging
167179
# SSH to investigate
168-
aws-vault exec dev -- nix run .#pg-ami-builder -- ssh
180+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- ssh
169181

170182
# Make local changes to ansible files
171183
vim ansible/playbook.yml
172184

173185
# Re-run with your local changes
174-
aws-vault exec dev -- nix run .#pg-ami-builder -- ansible-rerun phase1 --sync-files
186+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- ansible-rerun phase1 --sync-files
175187

176188
# Repeat until working, then create AMI
177-
aws-vault exec dev -- nix run .#pg-ami-builder -- build phase1 --postgres-version 15 --create-ami
189+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- build phase1 --postgres-version 15 --create-ami
178190

179191
# Cleanup
180-
aws-vault exec dev -- nix run .#pg-ami-builder -- cleanup
192+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- cleanup
181193
```
182194

183195
### Workflow 2: Parallel builds for multiple postgres versions
184196

185197
```bash
186198
# Build PG 15
187-
aws-vault exec dev -- nix run .#pg-ami-builder -- build phase1 \
199+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- build phase1 \
188200
--postgres-version 15 \
189201
--state-file ~/.pg-ami-build/pg15.json
190202

191203
# Build PG 16 in parallel
192-
aws-vault exec dev -- nix run .#pg-ami-builder -- build phase1 \
204+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- build phase1 \
193205
--postgres-version 16 \
194206
--state-file ~/.pg-ami-build/pg16.json
195207

196208
# SSH into PG 15 instance
197-
aws-vault exec dev -- nix run .#pg-ami-builder -- ssh \
209+
aws-vault exec <profile> -- nix run .#pg-ami-builder -- ssh \
198210
--state-file ~/.pg-ami-build/pg15.json
199211
```
200212

0 commit comments

Comments
 (0)