@codyswann/lisa 2.204.8 → 2.205.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/package.json +1 -1
  2. package/plugins/lisa/.claude-plugin/plugin.json +1 -1
  3. package/plugins/lisa/.codex-plugin/plugin.json +1 -1
  4. package/plugins/lisa-agy/plugin.json +1 -1
  5. package/plugins/lisa-cdk/.claude-plugin/plugin.json +1 -1
  6. package/plugins/lisa-cdk/.codex-plugin/plugin.json +2 -1
  7. package/plugins/lisa-cdk/.codex-plugin/skills/lisa-setup-aws/SKILL.md +13 -0
  8. package/plugins/lisa-cdk/.codex-plugin/skills/lisa-setup-aws/agents/openai.yaml +4 -0
  9. package/plugins/lisa-cdk/.codex-plugin/skills/setup-aws-accounts/SKILL.md +292 -0
  10. package/plugins/lisa-cdk/.codex-plugin/skills/setup-aws-accounts/agents/openai.yaml +4 -0
  11. package/plugins/lisa-cdk/commands/setup/aws.md +7 -0
  12. package/plugins/lisa-cdk/skills/setup-aws-accounts/SKILL.md +292 -0
  13. package/plugins/lisa-cdk/skills/setup-aws-accounts/agents/openai.yaml +4 -0
  14. package/plugins/lisa-cdk-agy/commands/lisa/setup/aws.md +7 -0
  15. package/plugins/lisa-cdk-agy/plugin.json +1 -1
  16. package/plugins/lisa-cdk-agy/skills/setup-aws-accounts/SKILL.md +292 -0
  17. package/plugins/lisa-cdk-copilot/.claude-plugin/plugin.json +1 -1
  18. package/plugins/lisa-cdk-copilot/commands/lisa/setup/aws.md +7 -0
  19. package/plugins/lisa-cdk-copilot/skills/setup-aws-accounts/SKILL.md +292 -0
  20. package/plugins/lisa-cdk-cursor/.claude-plugin/plugin.json +1 -1
  21. package/plugins/lisa-cdk-cursor/commands/lisa/setup/aws.md +7 -0
  22. package/plugins/lisa-cdk-cursor/skills/setup-aws-accounts/SKILL.md +292 -0
  23. package/plugins/lisa-copilot/.claude-plugin/plugin.json +1 -1
  24. package/plugins/lisa-cursor/.claude-plugin/plugin.json +1 -1
  25. package/plugins/lisa-expo/.claude-plugin/plugin.json +1 -1
  26. package/plugins/lisa-expo/.codex-plugin/plugin.json +1 -1
  27. package/plugins/lisa-expo-agy/plugin.json +1 -1
  28. package/plugins/lisa-expo-copilot/.claude-plugin/plugin.json +1 -1
  29. package/plugins/lisa-expo-cursor/.claude-plugin/plugin.json +1 -1
  30. package/plugins/lisa-harper-fabric/.claude-plugin/plugin.json +1 -1
  31. package/plugins/lisa-harper-fabric/.codex-plugin/plugin.json +1 -1
  32. package/plugins/lisa-harper-fabric-agy/plugin.json +1 -1
  33. package/plugins/lisa-harper-fabric-copilot/.claude-plugin/plugin.json +1 -1
  34. package/plugins/lisa-harper-fabric-cursor/.claude-plugin/plugin.json +1 -1
  35. package/plugins/lisa-nestjs/.claude-plugin/plugin.json +1 -1
  36. package/plugins/lisa-nestjs/.codex-plugin/plugin.json +1 -1
  37. package/plugins/lisa-nestjs-agy/plugin.json +1 -1
  38. package/plugins/lisa-nestjs-copilot/.claude-plugin/plugin.json +1 -1
  39. package/plugins/lisa-nestjs-cursor/.claude-plugin/plugin.json +1 -1
  40. package/plugins/lisa-openclaw/.claude-plugin/plugin.json +1 -1
  41. package/plugins/lisa-openclaw/.codex-plugin/plugin.json +1 -1
  42. package/plugins/lisa-openclaw-agy/plugin.json +1 -1
  43. package/plugins/lisa-openclaw-copilot/.claude-plugin/plugin.json +1 -1
  44. package/plugins/lisa-openclaw-cursor/.claude-plugin/plugin.json +1 -1
  45. package/plugins/lisa-phaser/.claude-plugin/plugin.json +1 -1
  46. package/plugins/lisa-phaser/.codex-plugin/plugin.json +1 -1
  47. package/plugins/lisa-phaser-agy/plugin.json +1 -1
  48. package/plugins/lisa-phaser-copilot/.claude-plugin/plugin.json +1 -1
  49. package/plugins/lisa-phaser-cursor/.claude-plugin/plugin.json +1 -1
  50. package/plugins/lisa-rails/.claude-plugin/plugin.json +1 -1
  51. package/plugins/lisa-rails/.codex-plugin/plugin.json +1 -1
  52. package/plugins/lisa-rails-agy/plugin.json +1 -1
  53. package/plugins/lisa-rails-copilot/.claude-plugin/plugin.json +1 -1
  54. package/plugins/lisa-rails-cursor/.claude-plugin/plugin.json +1 -1
  55. package/plugins/lisa-typescript/.claude-plugin/plugin.json +1 -1
  56. package/plugins/lisa-typescript/.codex-plugin/plugin.json +1 -1
  57. package/plugins/lisa-typescript-agy/plugin.json +1 -1
  58. package/plugins/lisa-typescript-copilot/.claude-plugin/plugin.json +1 -1
  59. package/plugins/lisa-typescript-cursor/.claude-plugin/plugin.json +1 -1
  60. package/plugins/lisa-wiki/.claude-plugin/plugin.json +1 -1
  61. package/plugins/lisa-wiki/.codex-plugin/plugin.json +1 -1
  62. package/plugins/lisa-wiki-agy/plugin.json +1 -1
  63. package/plugins/lisa-wiki-copilot/.claude-plugin/plugin.json +1 -1
  64. package/plugins/lisa-wiki-cursor/.claude-plugin/plugin.json +1 -1
  65. package/plugins/src/cdk/commands/setup/aws.md +7 -0
  66. package/plugins/src/cdk/skills/setup-aws-accounts/SKILL.md +292 -0
@@ -0,0 +1,292 @@
1
+ ---
2
+ name: setup-aws-accounts
3
+ description: "Provision the multi-account AWS environment a Lisa CDK project deploys into, using the @codyswann/aws-soc2-setup CLI (AWS Organizations, Control Tower, IAM Identity Center, SOC 2 controls). Use when a CDK project still has PLACEHOLDER account IDs in config/environments.ts, when asked to create the dev/staging/production/shared AWS accounts, or when CDK deploys fail because accounts, SSO profiles, or bootstrap are missing. Drives the CLI for the org + OU + security foundation and Account Factory account vending, writes the AWS SSO profiles the project's scripts expect, runs cdk bootstrap with cross-account pipeline trust, replaces PLACEHOLDER account IDs, sets the AWS_ACCOUNT_ID_* GitHub secrets when CI uses them, and records the account map in .lisa.config.json. Idempotent — safe to re-run. Console-only prerequisites (root MFA, enabling Identity Center, creating the Control Tower landing zone) are surfaced as an explicit human checklist, never automated."
4
+ allowed-tools: ["Bash", "Read", "Edit", "Write", "AskUserQuestion"]
5
+ ---
6
+
7
+ # Setup AWS Accounts (SOC 2 Landing Zone)
8
+
9
+ Provision and wire the AWS accounts a CDK project deploys into. The account
10
+ supply side runs through the [`@codyswann/aws-soc2-setup`](https://www.npmjs.com/package/@codyswann/aws-soc2-setup)
11
+ CLI (AWS Organizations, Control Tower, IAM Identity Center, security services,
12
+ SOC 2 controls); the demand side — profiles, `cdk bootstrap`, config files, CI
13
+ secrets — is wired by this skill so the project goes from `PLACEHOLDER` account
14
+ IDs to deployable in one flow.
15
+
16
+ ## When to use
17
+
18
+ - A CDK project's `config/environments.ts` still has `accountId: "PLACEHOLDER"`
19
+ entries, so `cdk deploy` silently skips those environments.
20
+ - The user asks to "create the AWS accounts", "set up dev/staging/production
21
+ accounts", "bootstrap AWS for this project", or similar.
22
+ - `scripts/pre-deployment-checklist.sh` fails because `<prefix>-<env>` AWS
23
+ profiles don't exist or don't authenticate.
24
+ - A fresh organization needs the SOC 2 foundation (Control Tower, guardrails,
25
+ security services) before workload accounts are vended.
26
+
27
+ Not for: deploying stacks (that's `cdk deploy` / CI), or GitHub repo governance
28
+ (that's `lisa-setup-github-repo`).
29
+
30
+ ## How the CLI behaves (read before scripting it)
31
+
32
+ - Invoke as `npx -y @codyswann/aws-soc2-setup@1 <command>`. Pin at least the
33
+ major version — an unpinned `npx` pull is a supply-chain risk for a tool that
34
+ runs with management-account credentials. Always set `NO_COLOR=1` so output
35
+ parses cleanly.
36
+ - It is an **actuator, not an API** — no `--json` output. Drive it for side
37
+ effects, then read authoritative state back with the plain `aws` CLI
38
+ (`aws organizations list-accounts`, `aws sts get-caller-identity`). Never
39
+ trust scraped text alone for account IDs.
40
+ - It is idempotent per resource (ensure-semantics against live AWS), so
41
+ re-running `setup` is safe — **except** `controltower provision-account`,
42
+ which is not deduped by name. Always check `aws organizations list-accounts`
43
+ before provisioning and skip accounts that already exist.
44
+ - `--dry-run` previews every mutating command; `status` and `whoami` are
45
+ read-only.
46
+ - `controltower provision-account -o` takes the OU **name** (e.g. `Workloads`);
47
+ `register-ou` and `enable-controls` take the OU **id/ARN**. Don't mix them up.
48
+
49
+ ## Step 1 — Assess the environment (read-only)
50
+
51
+ ```bash
52
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 whoami -p <management-profile> -r <region>
53
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 status -p <management-profile> -r <region>
54
+ ```
55
+
56
+ `status` reports five independent checks: credentials, Organizations,
57
+ recommended OUs, IAM Identity Center, member accounts.
58
+
59
+ **The human gate.** Three prerequisites are console-only and must never be
60
+ automated. If `status` shows Identity Center or the landing zone missing, stop
61
+ and present this checklist in plain language a non-technical operator can
62
+ follow, then end the run:
63
+
64
+ 1. Sign in to the AWS console as the account **root** user and enable MFA on
65
+ the root account.
66
+ 2. In the console, enable **IAM Identity Center** (in your home region).
67
+ 3. In the console, create the **AWS Control Tower landing zone** (this creates
68
+ the Audit and Log Archive accounts; takes ~30–60 minutes).
69
+ 4. Configure a management-account admin profile locally:
70
+ `aws configure sso` (interactive).
71
+
72
+ Re-run this skill after those are done — Step 1 will pass and the flow
73
+ continues from wherever it left off.
74
+
75
+ ## Step 2 — Gather inputs
76
+
77
+ Collect (via arguments if provided, `AskUserQuestion` otherwise; use stated
78
+ defaults when running unattended):
79
+
80
+ | Input | Default | Notes |
81
+ | --- | --- | --- |
82
+ | Management profile | `AWS_PROFILE` | Must be the org management account |
83
+ | Region | `us-east-1` | Match the project's `config/environments.ts` |
84
+ | Profile prefix | project name from `package.json` | Matches `AWS_PROFILE_PREFIX` used by `scripts/pre-deployment-checklist.sh` |
85
+ | Environments | `dev`, `staging`, `production`, `shared` | `shared` hosts the pipeline and gets cross-account trust |
86
+ | Root email pattern | ask — no safe default | Each account needs a **unique** root email; suggest plus-addressing: `aws+<prefix>-<env>@<domain>` |
87
+ | Identity Center username | ask — no safe default | The Identity Store user that gets `AWSAdministratorAccess` on each new account in Step 5; verify it exists (create with `sso create-user` if not) |
88
+ | Identity Center start URL | from `status` output or the console | The **full** `sso_start_url` for the `sso-session` block in Step 5 (default form `https://<domain>.awsapps.com/start`, but custom domains differ — never reconstruct it from parts) |
89
+
90
+ ## Step 3 — Foundation (org, OUs, controls, security services)
91
+
92
+ Show the plan, get explicit approval, then apply:
93
+
94
+ ```bash
95
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 setup --dry-run -p <mgmt> -r <region>
96
+ ```
97
+
98
+ Present the dry-run output and **stop for confirmation** before mutating the
99
+ organization — `AskUserQuestion` when interactive, or an unambiguous
100
+ apply/confirm argument from the caller when running unattended. Silence is not
101
+ approval. Only then:
102
+
103
+ ```bash
104
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 setup -p <mgmt> -r <region> \
105
+ [--ou <workloads-ou-id>] [--central-account <id>] [--admin-account <id>] [--audit-account <id>]
106
+ ```
107
+
108
+ This ensures the organization, creates the Infrastructure/Workloads/Sandbox
109
+ OUs, enables the security services (GuardDuty, Security Hub, Config, …),
110
+ conformance packs, and — when `--ou` is passed — registers the OU with Control
111
+ Tower and enables the SOC 2 control baseline. Safe to re-run.
112
+
113
+ ## Step 4 — Vend the workload accounts
114
+
115
+ For each environment, **first** check it doesn't already exist:
116
+
117
+ ```bash
118
+ aws organizations list-accounts --profile <mgmt> \
119
+ --query "Accounts[?Name=='<prefix>-<env>'].{Id:Id,Name:Name,State:State}" --output table
120
+ ```
121
+
122
+ (Use `State`, not `Status` — AWS is retiring the `Status` field in favor of
123
+ `State`.)
124
+
125
+ Then provision the missing ones, one at a time, each with a unique root email.
126
+ Stage accounts go into the `Workloads` OU:
127
+
128
+ ```bash
129
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 controltower provision-account \
130
+ -p <mgmt> -r <region> \
131
+ -n <prefix>-<env> -e aws+<prefix>-<env>@<domain> -o Workloads --wait
132
+ ```
133
+
134
+ The `shared` (pipeline) account goes into `Infrastructure` instead:
135
+
136
+ ```bash
137
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 controltower provision-account \
138
+ -p <mgmt> -r <region> \
139
+ -n <prefix>-shared -e aws+<prefix>-shared@<domain> -o Infrastructure --wait
140
+ ```
141
+
142
+ `--wait` polls Account Factory (~minutes per account) and prints
143
+ `New account ID: <id>`. After all accounts finish, harvest the authoritative
144
+ env → account-ID map from `aws organizations list-accounts` — that map drives
145
+ every later step.
146
+
147
+ ## Step 5 — Identity Center access + local AWS profiles
148
+
149
+ Grant the operator admin on each new account, using the Identity Center
150
+ username collected in Step 2:
151
+
152
+ ```bash
153
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 sso assign \
154
+ -p <mgmt> -u <username> -a <account-id> -r AWSAdministratorAccess
155
+ ```
156
+
157
+ (or `sso group -g <prefix>-admins --all-users -a <account-id> -r AWSAdministratorAccess`
158
+ for group-based access. If the user doesn't exist yet, create it first with
159
+ `sso create-user`.)
160
+
161
+ The CLI does **not** generate AWS CLI profiles — write them yourself. Append to
162
+ `~/.aws/config` (never overwrite existing sections; skip blocks that already
163
+ exist):
164
+
165
+ ```ini
166
+ [sso-session <prefix>]
167
+ sso_start_url = <start-url>
168
+ sso_region = <region>
169
+ sso_registration_scopes = sso:account:access
170
+
171
+ [profile <prefix>-dev]
172
+ sso_session = <prefix>
173
+ sso_account_id = <dev-account-id>
174
+ sso_role_name = AWSAdministratorAccess
175
+ region = <region>
176
+ ```
177
+
178
+ `<start-url>` is the full Identity Center start URL collected in Step 2 —
179
+ paste it verbatim, never rebuild it from a domain fragment. One
180
+ `[profile <prefix>-<env>]` block per environment — this exact naming is
181
+ what `scripts/pre-deployment-checklist.sh` and the db-connect scripts resolve.
182
+ Then authenticate and verify every profile maps to the expected account:
183
+
184
+ ```bash
185
+ aws sso login --sso-session <prefix>
186
+ for env in dev staging production shared; do
187
+ aws sts get-caller-identity --profile <prefix>-$env --query Account --output text
188
+ done
189
+ ```
190
+
191
+ ## Step 6 — CDK bootstrap with pipeline trust
192
+
193
+ Bootstrap the shared (pipeline) account first, then each stage account with
194
+ trust back to shared. Honor the project's `CDK_BOOTSTRAP_QUALIFIER` and
195
+ `CDK_BOOTSTRAP_EXECUTION_POLICY_ARN` env vars rather than hardcoding their
196
+ defaults (`config/env.ts` defaults: `hnb659fds` /
197
+ `arn:aws:iam::aws:policy/AdministratorAccess`):
198
+
199
+ ```bash
200
+ qualifier="${CDK_BOOTSTRAP_QUALIFIER:-hnb659fds}"
201
+ exec_policy="${CDK_BOOTSTRAP_EXECUTION_POLICY_ARN:-arn:aws:iam::aws:policy/AdministratorAccess}"
202
+
203
+ npx cdk bootstrap aws://<shared-id>/<region> --profile <prefix>-shared \
204
+ --qualifier "$qualifier"
205
+
206
+ for env in dev staging production; do
207
+ npx cdk bootstrap aws://<env-id>/<region> --profile <prefix>-$env \
208
+ --qualifier "$qualifier" \
209
+ --trust <shared-id> \
210
+ --cloudformation-execution-policies "$exec_policy"
211
+ done
212
+ ```
213
+
214
+ The `--trust` flag is the manual chicken-and-egg step the project's
215
+ `trust-policy-stack` documents as CfnOutputs — this skill is where it actually
216
+ runs.
217
+
218
+ ## Step 7 — Wire the project
219
+
220
+ 1. **`config/environments.ts`** (when the project has it): replace each
221
+ environment's `accountId: "PLACEHOLDER"` with the real 12-digit ID from the
222
+ Step 4 map, and confirm `region` matches. This single edit is what flips
223
+ each environment from synth-only to deployable. If the project uses a
224
+ different layout, skip with a note — the `.lisa.config.json` record below
225
+ still applies.
226
+ 2. **GitHub secrets** — only when `.github/workflows/ci.yml` references them:
227
+ ```bash
228
+ gh secret set AWS_ACCOUNT_ID_DEV --body "<dev-id>"
229
+ gh secret set AWS_ACCOUNT_ID_STAGING --body "<staging-id>"
230
+ gh secret set AWS_ACCOUNT_ID_PRODUCTION --body "<production-id>"
231
+ gh secret set AWS_INFRA_ACCOUNT_ID --body "<shared-id>"
232
+ ```
233
+ 3. **`.lisa.config.json`** — record the machine-readable account map (merge
234
+ with `jq`, preserving every other key):
235
+ ```json
236
+ {
237
+ "aws": {
238
+ "region": "<region>",
239
+ "profilePrefix": "<prefix>",
240
+ "accounts": {
241
+ "dev": "<dev-id>",
242
+ "staging": "<staging-id>",
243
+ "production": "<production-id>",
244
+ "shared": "<shared-id>"
245
+ }
246
+ }
247
+ }
248
+ ```
249
+
250
+ ## Step 8 — Verify and report
251
+
252
+ - Every `<prefix>-<env>` profile authenticates to its expected account ID
253
+ (`aws sts get-caller-identity`).
254
+ - `scripts/pre-deployment-checklist.sh` passes when the project ships it.
255
+ - `npx cdk synth` succeeds and no environment is skipped as non-deployable.
256
+ - Report a table: environment → account ID → profile → bootstrapped (yes/no).
257
+ - Name what remains manual, in operator-readable language — e.g. the GitHub
258
+ CodeConnections handshake for pipeline mode (`config/github.ts`
259
+ `codeConnectionArn`) is an interactive console step outside this skill's
260
+ scope, and hardening extras (`root remove-access`, `scp deny-iam-users`,
261
+ `scp alert-management`) are offered but require explicit confirmation since
262
+ they are org-wide and destructive.
263
+
264
+ ## Cross-agent invocation
265
+
266
+ The same SKILL.md ships to every supported runtime via the plugin build; all
267
+ logic lives here, never in the command shim.
268
+
269
+ - Claude Code / OpenCode / Cursor: `/lisa-cdk:setup:aws` command, or invoke the
270
+ skill directly.
271
+ - Codex (no slash commands): `$setup-aws-accounts` (the command shim also
272
+ installs as `$lisa-setup-aws`).
273
+ - agy / Copilot: the skill is delivered through the generated plugin variants;
274
+ invoke it by name.
275
+
276
+ ## Rules
277
+
278
+ - **Never automate the console-only steps** (root MFA, enabling Identity
279
+ Center, landing zone creation). Present the checklist, stop, and let a human
280
+ do them. Every blocked reason must be readable by a non-technical operator.
281
+ - Always `--dry-run` (or `status`) first and show the plan before mutating an
282
+ organization. `root` and `scp` subcommands are destructive org-wide — never
283
+ run them without explicit user confirmation in this session.
284
+ - Check before create: `list-accounts` before `provision-account`; read
285
+ `~/.aws/config` before appending profile blocks; never clobber existing
286
+ profiles or config keys.
287
+ - Harvest account IDs from `aws organizations list-accounts`, not from scraped
288
+ CLI text.
289
+ - Never write credentials or secrets into the repository. Account IDs are not
290
+ secret and belong in config; keys and tokens never do.
291
+ - Do not stage or modify unrelated working-tree files; the only repo edits are
292
+ `config/environments.ts` and `.lisa.config.json`.
@@ -0,0 +1,4 @@
1
+ display_name: "Setup AWS Accounts"
2
+ short_description: "Provision the multi-account AWS environment a Lisa CDK project deploys into, using the @codyswann/aws-soc2-setup CLI (AWS Organizations…"
3
+ default_prompt:
4
+ - "Use $setup-aws-accounts: Provision the multi-account AWS environment a Lisa CDK project deploys into, using the @codyswann/aws-soc2-setup CLI (AWS Organizations…."
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: "Provision the dev/staging/production/shared AWS accounts this CDK project deploys into via the @codyswann/aws-soc2-setup CLI (Organizations, Control Tower, IAM Identity Center, SOC 2 controls), then wire them in end-to-end: SSO profiles, cdk bootstrap with pipeline trust, PLACEHOLDER account IDs in config/environments.ts, AWS_ACCOUNT_ID_* GitHub secrets, and the .lisa.config.json account map. Idempotent; console-only prerequisites (root MFA, Identity Center, landing zone) surface as a human checklist instead of being automated."
3
+ allowed-tools: ["Skill"]
4
+ argument-hint: "[management-profile] [region] [dry-run]"
5
+ ---
6
+
7
+ Use the setup-aws-accounts skill (/lisa-cdk:setup-aws-accounts on harnesses with plugin commands; $setup-aws-accounts on Codex) to assess the AWS organization, run the aws-soc2-setup foundation and account vending, write the SSO profiles, cdk-bootstrap every account with cross-account trust, and wire the resulting account IDs into config/environments.ts, GitHub secrets, and .lisa.config.json. $ARGUMENTS
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.204.8",
3
+ "version": "2.205.0",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -0,0 +1,292 @@
1
+ ---
2
+ name: setup-aws-accounts
3
+ description: "Provision the multi-account AWS environment a Lisa CDK project deploys into, using the @codyswann/aws-soc2-setup CLI (AWS Organizations, Control Tower, IAM Identity Center, SOC 2 controls). Use when a CDK project still has PLACEHOLDER account IDs in config/environments.ts, when asked to create the dev/staging/production/shared AWS accounts, or when CDK deploys fail because accounts, SSO profiles, or bootstrap are missing. Drives the CLI for the org + OU + security foundation and Account Factory account vending, writes the AWS SSO profiles the project's scripts expect, runs cdk bootstrap with cross-account pipeline trust, replaces PLACEHOLDER account IDs, sets the AWS_ACCOUNT_ID_* GitHub secrets when CI uses them, and records the account map in .lisa.config.json. Idempotent — safe to re-run. Console-only prerequisites (root MFA, enabling Identity Center, creating the Control Tower landing zone) are surfaced as an explicit human checklist, never automated."
4
+ allowed-tools: ["Bash", "Read", "Edit", "Write", "AskUserQuestion"]
5
+ ---
6
+
7
+ # Setup AWS Accounts (SOC 2 Landing Zone)
8
+
9
+ Provision and wire the AWS accounts a CDK project deploys into. The account
10
+ supply side runs through the [`@codyswann/aws-soc2-setup`](https://www.npmjs.com/package/@codyswann/aws-soc2-setup)
11
+ CLI (AWS Organizations, Control Tower, IAM Identity Center, security services,
12
+ SOC 2 controls); the demand side — profiles, `cdk bootstrap`, config files, CI
13
+ secrets — is wired by this skill so the project goes from `PLACEHOLDER` account
14
+ IDs to deployable in one flow.
15
+
16
+ ## When to use
17
+
18
+ - A CDK project's `config/environments.ts` still has `accountId: "PLACEHOLDER"`
19
+ entries, so `cdk deploy` silently skips those environments.
20
+ - The user asks to "create the AWS accounts", "set up dev/staging/production
21
+ accounts", "bootstrap AWS for this project", or similar.
22
+ - `scripts/pre-deployment-checklist.sh` fails because `<prefix>-<env>` AWS
23
+ profiles don't exist or don't authenticate.
24
+ - A fresh organization needs the SOC 2 foundation (Control Tower, guardrails,
25
+ security services) before workload accounts are vended.
26
+
27
+ Not for: deploying stacks (that's `cdk deploy` / CI), or GitHub repo governance
28
+ (that's `lisa-setup-github-repo`).
29
+
30
+ ## How the CLI behaves (read before scripting it)
31
+
32
+ - Invoke as `npx -y @codyswann/aws-soc2-setup@1 <command>`. Pin at least the
33
+ major version — an unpinned `npx` pull is a supply-chain risk for a tool that
34
+ runs with management-account credentials. Always set `NO_COLOR=1` so output
35
+ parses cleanly.
36
+ - It is an **actuator, not an API** — no `--json` output. Drive it for side
37
+ effects, then read authoritative state back with the plain `aws` CLI
38
+ (`aws organizations list-accounts`, `aws sts get-caller-identity`). Never
39
+ trust scraped text alone for account IDs.
40
+ - It is idempotent per resource (ensure-semantics against live AWS), so
41
+ re-running `setup` is safe — **except** `controltower provision-account`,
42
+ which is not deduped by name. Always check `aws organizations list-accounts`
43
+ before provisioning and skip accounts that already exist.
44
+ - `--dry-run` previews every mutating command; `status` and `whoami` are
45
+ read-only.
46
+ - `controltower provision-account -o` takes the OU **name** (e.g. `Workloads`);
47
+ `register-ou` and `enable-controls` take the OU **id/ARN**. Don't mix them up.
48
+
49
+ ## Step 1 — Assess the environment (read-only)
50
+
51
+ ```bash
52
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 whoami -p <management-profile> -r <region>
53
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 status -p <management-profile> -r <region>
54
+ ```
55
+
56
+ `status` reports five independent checks: credentials, Organizations,
57
+ recommended OUs, IAM Identity Center, member accounts.
58
+
59
+ **The human gate.** Three prerequisites are console-only and must never be
60
+ automated. If `status` shows Identity Center or the landing zone missing, stop
61
+ and present this checklist in plain language a non-technical operator can
62
+ follow, then end the run:
63
+
64
+ 1. Sign in to the AWS console as the account **root** user and enable MFA on
65
+ the root account.
66
+ 2. In the console, enable **IAM Identity Center** (in your home region).
67
+ 3. In the console, create the **AWS Control Tower landing zone** (this creates
68
+ the Audit and Log Archive accounts; takes ~30–60 minutes).
69
+ 4. Configure a management-account admin profile locally:
70
+ `aws configure sso` (interactive).
71
+
72
+ Re-run this skill after those are done — Step 1 will pass and the flow
73
+ continues from wherever it left off.
74
+
75
+ ## Step 2 — Gather inputs
76
+
77
+ Collect (via arguments if provided, `AskUserQuestion` otherwise; use stated
78
+ defaults when running unattended):
79
+
80
+ | Input | Default | Notes |
81
+ | --- | --- | --- |
82
+ | Management profile | `AWS_PROFILE` | Must be the org management account |
83
+ | Region | `us-east-1` | Match the project's `config/environments.ts` |
84
+ | Profile prefix | project name from `package.json` | Matches `AWS_PROFILE_PREFIX` used by `scripts/pre-deployment-checklist.sh` |
85
+ | Environments | `dev`, `staging`, `production`, `shared` | `shared` hosts the pipeline and gets cross-account trust |
86
+ | Root email pattern | ask — no safe default | Each account needs a **unique** root email; suggest plus-addressing: `aws+<prefix>-<env>@<domain>` |
87
+ | Identity Center username | ask — no safe default | The Identity Store user that gets `AWSAdministratorAccess` on each new account in Step 5; verify it exists (create with `sso create-user` if not) |
88
+ | Identity Center start URL | from `status` output or the console | The **full** `sso_start_url` for the `sso-session` block in Step 5 (default form `https://<domain>.awsapps.com/start`, but custom domains differ — never reconstruct it from parts) |
89
+
90
+ ## Step 3 — Foundation (org, OUs, controls, security services)
91
+
92
+ Show the plan, get explicit approval, then apply:
93
+
94
+ ```bash
95
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 setup --dry-run -p <mgmt> -r <region>
96
+ ```
97
+
98
+ Present the dry-run output and **stop for confirmation** before mutating the
99
+ organization — `AskUserQuestion` when interactive, or an unambiguous
100
+ apply/confirm argument from the caller when running unattended. Silence is not
101
+ approval. Only then:
102
+
103
+ ```bash
104
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 setup -p <mgmt> -r <region> \
105
+ [--ou <workloads-ou-id>] [--central-account <id>] [--admin-account <id>] [--audit-account <id>]
106
+ ```
107
+
108
+ This ensures the organization, creates the Infrastructure/Workloads/Sandbox
109
+ OUs, enables the security services (GuardDuty, Security Hub, Config, …),
110
+ conformance packs, and — when `--ou` is passed — registers the OU with Control
111
+ Tower and enables the SOC 2 control baseline. Safe to re-run.
112
+
113
+ ## Step 4 — Vend the workload accounts
114
+
115
+ For each environment, **first** check it doesn't already exist:
116
+
117
+ ```bash
118
+ aws organizations list-accounts --profile <mgmt> \
119
+ --query "Accounts[?Name=='<prefix>-<env>'].{Id:Id,Name:Name,State:State}" --output table
120
+ ```
121
+
122
+ (Use `State`, not `Status` — AWS is retiring the `Status` field in favor of
123
+ `State`.)
124
+
125
+ Then provision the missing ones, one at a time, each with a unique root email.
126
+ Stage accounts go into the `Workloads` OU:
127
+
128
+ ```bash
129
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 controltower provision-account \
130
+ -p <mgmt> -r <region> \
131
+ -n <prefix>-<env> -e aws+<prefix>-<env>@<domain> -o Workloads --wait
132
+ ```
133
+
134
+ The `shared` (pipeline) account goes into `Infrastructure` instead:
135
+
136
+ ```bash
137
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 controltower provision-account \
138
+ -p <mgmt> -r <region> \
139
+ -n <prefix>-shared -e aws+<prefix>-shared@<domain> -o Infrastructure --wait
140
+ ```
141
+
142
+ `--wait` polls Account Factory (~minutes per account) and prints
143
+ `New account ID: <id>`. After all accounts finish, harvest the authoritative
144
+ env → account-ID map from `aws organizations list-accounts` — that map drives
145
+ every later step.
146
+
147
+ ## Step 5 — Identity Center access + local AWS profiles
148
+
149
+ Grant the operator admin on each new account, using the Identity Center
150
+ username collected in Step 2:
151
+
152
+ ```bash
153
+ NO_COLOR=1 npx -y @codyswann/aws-soc2-setup@1 sso assign \
154
+ -p <mgmt> -u <username> -a <account-id> -r AWSAdministratorAccess
155
+ ```
156
+
157
+ (or `sso group -g <prefix>-admins --all-users -a <account-id> -r AWSAdministratorAccess`
158
+ for group-based access. If the user doesn't exist yet, create it first with
159
+ `sso create-user`.)
160
+
161
+ The CLI does **not** generate AWS CLI profiles — write them yourself. Append to
162
+ `~/.aws/config` (never overwrite existing sections; skip blocks that already
163
+ exist):
164
+
165
+ ```ini
166
+ [sso-session <prefix>]
167
+ sso_start_url = <start-url>
168
+ sso_region = <region>
169
+ sso_registration_scopes = sso:account:access
170
+
171
+ [profile <prefix>-dev]
172
+ sso_session = <prefix>
173
+ sso_account_id = <dev-account-id>
174
+ sso_role_name = AWSAdministratorAccess
175
+ region = <region>
176
+ ```
177
+
178
+ `<start-url>` is the full Identity Center start URL collected in Step 2 —
179
+ paste it verbatim, never rebuild it from a domain fragment. One
180
+ `[profile <prefix>-<env>]` block per environment — this exact naming is
181
+ what `scripts/pre-deployment-checklist.sh` and the db-connect scripts resolve.
182
+ Then authenticate and verify every profile maps to the expected account:
183
+
184
+ ```bash
185
+ aws sso login --sso-session <prefix>
186
+ for env in dev staging production shared; do
187
+ aws sts get-caller-identity --profile <prefix>-$env --query Account --output text
188
+ done
189
+ ```
190
+
191
+ ## Step 6 — CDK bootstrap with pipeline trust
192
+
193
+ Bootstrap the shared (pipeline) account first, then each stage account with
194
+ trust back to shared. Honor the project's `CDK_BOOTSTRAP_QUALIFIER` and
195
+ `CDK_BOOTSTRAP_EXECUTION_POLICY_ARN` env vars rather than hardcoding their
196
+ defaults (`config/env.ts` defaults: `hnb659fds` /
197
+ `arn:aws:iam::aws:policy/AdministratorAccess`):
198
+
199
+ ```bash
200
+ qualifier="${CDK_BOOTSTRAP_QUALIFIER:-hnb659fds}"
201
+ exec_policy="${CDK_BOOTSTRAP_EXECUTION_POLICY_ARN:-arn:aws:iam::aws:policy/AdministratorAccess}"
202
+
203
+ npx cdk bootstrap aws://<shared-id>/<region> --profile <prefix>-shared \
204
+ --qualifier "$qualifier"
205
+
206
+ for env in dev staging production; do
207
+ npx cdk bootstrap aws://<env-id>/<region> --profile <prefix>-$env \
208
+ --qualifier "$qualifier" \
209
+ --trust <shared-id> \
210
+ --cloudformation-execution-policies "$exec_policy"
211
+ done
212
+ ```
213
+
214
+ The `--trust` flag is the manual chicken-and-egg step the project's
215
+ `trust-policy-stack` documents as CfnOutputs — this skill is where it actually
216
+ runs.
217
+
218
+ ## Step 7 — Wire the project
219
+
220
+ 1. **`config/environments.ts`** (when the project has it): replace each
221
+ environment's `accountId: "PLACEHOLDER"` with the real 12-digit ID from the
222
+ Step 4 map, and confirm `region` matches. This single edit is what flips
223
+ each environment from synth-only to deployable. If the project uses a
224
+ different layout, skip with a note — the `.lisa.config.json` record below
225
+ still applies.
226
+ 2. **GitHub secrets** — only when `.github/workflows/ci.yml` references them:
227
+ ```bash
228
+ gh secret set AWS_ACCOUNT_ID_DEV --body "<dev-id>"
229
+ gh secret set AWS_ACCOUNT_ID_STAGING --body "<staging-id>"
230
+ gh secret set AWS_ACCOUNT_ID_PRODUCTION --body "<production-id>"
231
+ gh secret set AWS_INFRA_ACCOUNT_ID --body "<shared-id>"
232
+ ```
233
+ 3. **`.lisa.config.json`** — record the machine-readable account map (merge
234
+ with `jq`, preserving every other key):
235
+ ```json
236
+ {
237
+ "aws": {
238
+ "region": "<region>",
239
+ "profilePrefix": "<prefix>",
240
+ "accounts": {
241
+ "dev": "<dev-id>",
242
+ "staging": "<staging-id>",
243
+ "production": "<production-id>",
244
+ "shared": "<shared-id>"
245
+ }
246
+ }
247
+ }
248
+ ```
249
+
250
+ ## Step 8 — Verify and report
251
+
252
+ - Every `<prefix>-<env>` profile authenticates to its expected account ID
253
+ (`aws sts get-caller-identity`).
254
+ - `scripts/pre-deployment-checklist.sh` passes when the project ships it.
255
+ - `npx cdk synth` succeeds and no environment is skipped as non-deployable.
256
+ - Report a table: environment → account ID → profile → bootstrapped (yes/no).
257
+ - Name what remains manual, in operator-readable language — e.g. the GitHub
258
+ CodeConnections handshake for pipeline mode (`config/github.ts`
259
+ `codeConnectionArn`) is an interactive console step outside this skill's
260
+ scope, and hardening extras (`root remove-access`, `scp deny-iam-users`,
261
+ `scp alert-management`) are offered but require explicit confirmation since
262
+ they are org-wide and destructive.
263
+
264
+ ## Cross-agent invocation
265
+
266
+ The same SKILL.md ships to every supported runtime via the plugin build; all
267
+ logic lives here, never in the command shim.
268
+
269
+ - Claude Code / OpenCode / Cursor: `/lisa-cdk:setup:aws` command, or invoke the
270
+ skill directly.
271
+ - Codex (no slash commands): `$setup-aws-accounts` (the command shim also
272
+ installs as `$lisa-setup-aws`).
273
+ - agy / Copilot: the skill is delivered through the generated plugin variants;
274
+ invoke it by name.
275
+
276
+ ## Rules
277
+
278
+ - **Never automate the console-only steps** (root MFA, enabling Identity
279
+ Center, landing zone creation). Present the checklist, stop, and let a human
280
+ do them. Every blocked reason must be readable by a non-technical operator.
281
+ - Always `--dry-run` (or `status`) first and show the plan before mutating an
282
+ organization. `root` and `scp` subcommands are destructive org-wide — never
283
+ run them without explicit user confirmation in this session.
284
+ - Check before create: `list-accounts` before `provision-account`; read
285
+ `~/.aws/config` before appending profile blocks; never clobber existing
286
+ profiles or config keys.
287
+ - Harvest account IDs from `aws organizations list-accounts`, not from scraped
288
+ CLI text.
289
+ - Never write credentials or secrets into the repository. Account IDs are not
290
+ secret and belong in config; keys and tokens never do.
291
+ - Do not stage or modify unrelated working-tree files; the only repo edits are
292
+ `config/environments.ts` and `.lisa.config.json`.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lisa-cdk",
3
- "version": "2.204.8",
3
+ "version": "2.205.0",
4
4
  "description": "AWS CDK-specific plugin",
5
5
  "author": {
6
6
  "name": "Cody Swann"
@@ -0,0 +1,7 @@
1
+ ---
2
+ description: "Provision the dev/staging/production/shared AWS accounts this CDK project deploys into via the @codyswann/aws-soc2-setup CLI (Organizations, Control Tower, IAM Identity Center, SOC 2 controls), then wire them in end-to-end: SSO profiles, cdk bootstrap with pipeline trust, PLACEHOLDER account IDs in config/environments.ts, AWS_ACCOUNT_ID_* GitHub secrets, and the .lisa.config.json account map. Idempotent; console-only prerequisites (root MFA, Identity Center, landing zone) surface as a human checklist instead of being automated."
3
+ allowed-tools: ["Skill"]
4
+ argument-hint: "[management-profile] [region] [dry-run]"
5
+ ---
6
+
7
+ Use the setup-aws-accounts skill (/lisa-cdk:setup-aws-accounts on harnesses with plugin commands; $setup-aws-accounts on Codex) to assess the AWS organization, run the aws-soc2-setup foundation and account vending, write the SSO profiles, cdk-bootstrap every account with cross-account trust, and wire the resulting account IDs into config/environments.ts, GitHub secrets, and .lisa.config.json. $ARGUMENTS