Files
acdl/terraform/bootstrap/README.md
T
Jon Chery e5d8dadbd4 feat(P56): IAM re-bootstrap live step — managed policy + OIDC role
D-095 RESOLVED. User provided fresh root credentials in .env.secrets;
the run resumed and applied the IAM baseline against account
581513795199.

Live actions (2026-07-28):
1. Converted spike_runner_policy.json from an inline user policy to a
   customer-managed policy acdl-spike-runner-policy (ARN
   arn:aws:iam::581513795199:policy/acdl-spike-runner-policy). The
   extended policy (5917 bytes) exceeded the 2048-byte inline limit;
   the managed-policy path supports 6144 bytes per version + 5
   versions. Inline policy deleted; managed policy attached.
2. Re-created the acdl-act-runner-role OIDC role (CAP-022 — was gone
   since Phase 08). Trust policy permits root assume until
   go-gitea/gitea#36988 merges real OIDC federation. Same managed
   policy attached so the runner inherits spike-runner-equivalent
   permissions, no long-lived key needed.

Grant verification (all OK):
- cloudfront:ListDistributions — OK (0 items, stacks not yet deployed)
- wafv2:ListWebAcls(CLOUDFRONT) — OK
- lambda:ListFunctions — OK
- dynamodb:DescribeTable(acdl-contracts) — ResourceNotFound (table not
  yet created — Phase 57 applies it; grant works, no AccessDenied)
- ce:GetCostAndUsage (7-day window) — OK (7 results — Phase 59 queries
  the full window)
- secretsmanager:ListSecrets — OK
- sns:ListTopics — OK
- iam:GetRole(acdl-act-runner-role) — OK

terraform/bootstrap/apply_iam_baseline.py — new idempotent script that
records the live step (create/version managed policy, attach to user +
role, delete leftover inline, ensure runner role). Re-ran to confirm
idempotency (created v2, deleted v1).

.ciagent/IAM_POLICY.md — updated with the managed-policy note, the
OIDC role ARN + trust policy, the grant verification table, and the
D-095 resolution note.

terraform/bootstrap/README.md — added the v1.11 Phase 56 section
documenting apply_iam_baseline.py.

Baseline test: 15/15 pass.

---ci---
project: acdl
phase: 56
milestone: v1.11
status: execute
escalation:
  type: deploy
  id: D-095
  status: resolved
  resolved_at: 2026-07-28
  resolution: user provided fresh root credentials in .env.secrets;
    managed policy applied + OIDC role re-created
---/ci---
2026-07-28 13:01:28 +00:00

4.4 KiB

ACDL v1.1 Spike — AWS Bootstrap Runbook

Phase 08 bootstraps the AWS engine for the v1.1 spike. It uses the root account credential for account 581513795199 exactly once, then closes D-034 by having the user manually rotate the root key afterward.

Spike scope (D-039): the spike uses a per-run-rotated IAM user key (acdl-spike-runner), NOT OIDC. Real OIDC federation is deferred to v1.2 (blocked on go-gitea/gitea#36988 — Gitea Actions does not support id-token: write). The acdl-spike-runner user + its key are deleted in v1.2 cleanup when the OIDC role lands.

Steps

  1. Set the bootstrap root key in env (never commit, never echo):

    export ACDL_BOOTSTRAP_AWS_ACCESS_KEY_ID="<root key>"
    export ACDL_BOOTSTRAP_AWS_SECRET_ACCESS_KEY="<root secret>"
    export AWS_DEFAULT_REGION="us-east-1"
    
  2. Create the state backend (S3 bucket + DynamoDB outbox table):

    python3 terraform/bootstrap/create_state_backend.py
    

    Idempotent; writes terraform/bootstrap/.bootstrap_state.json marker.

  3. Create the IAM user + scoped policy + initial key:

    python3 terraform/bootstrap/create_iam_user.py
    

    Prints ACDL_AWS_ACCESS_KEY_ID=<...> + ACDL_AWS_SECRET_ACCESS_KEY=<...> to stdout (capture if you want the initial key; rotate_spike_key.sh creates a fresh one anyway).

  4. Rotate the spike key (creates a new key, deactivates+deletes old, writes the new key to gitignored .env.secrets):

    bash scripts/rotate_spike_key.sh
    

    Optionally uploads to Gitea Actions secrets if ACDL_GITEA_TOKEN is set.

  5. Verify (manual): confirm the caller identity is acdl-spike-runner (not root); the S3 bucket + DynamoDB table + IAM user + scoped policy all exist; .env.secrets + .bootstrap_state.json are gitignored. (scripts/verify_phase08.sh was the automated gate; it has been removed along with all other per-phase verify scripts.)

  6. MANUAL — D-034 closure: rotate/deactivate the root key in the AWS IAM console (the user does this, not the script). The bootstrap root key has now served its one-shot purpose; the spike uses the rotated acdl-spike-runner key for Phases 09-10.

v1.11 Phase 56 — IAM re-bootstrap + OIDC role (REQ-116)

The v1.11 milestone re-bootstraps IAM to close G-005 (CAP-017..022 deploy-unverified). Phase 56 extends the spike-runner policy with CloudFront/WAF/Lambda/DynamoDB-contracts/SecretsManager/SNS/CE/KMS/OIDC permissions and re-creates the acdl-act-runner-role (CAP-022).

Apply the IAM baseline (idempotent):

export ACDL_BOOTSTRAP_AWS_ACCESS_KEY_ID="<root key>"
export ACDL_BOOTSTRAP_AWS_SECRET_ACCESS_KEY="<root secret>"
export AWS_DEFAULT_REGION="us-east-1"
python3 terraform/bootstrap/apply_iam_baseline.py

This script:

  1. Creates (or versions) the customer-managed policy acdl-spike-runner-policy from terraform/bootstrap/spike_runner_policy.json (ARN arn:aws:iam::581513795199:policy/acdl-spike-runner-policy).
  2. Attaches it to the acdl-spike-runner user and deletes any leftover inline policy (the v1.1 inline policy hit the 2048-byte limit; the managed-policy path supports 6144 bytes per version + up to 5 versions).
  3. Re-creates the acdl-act-runner-role OIDC role if absent, attaches the same managed policy, and sets a trust policy that permits root assume until go-gitea/gitea#36988 merges real OIDC federation.

The applied policy is documented in .ciagent/IAM_POLICY.md and regression-tested by tests/test_iam_policy_baseline.py (15 tests).

What the spike uses for Phases 09-10

  • State backend: S3 bucket acdl-tfstate-581513795199-us-east-1 + DynamoDB table acdl-outbox (one table for both lock + outbox, D-P08-1).
  • Auth: the rotated acdl-spike-runner key in .env.secrets (gitignored, chmod 600). Re-rotate after each spike run via rotate_spike_key.sh (D-039).

Spike scope vs v1.2 boundary

Concern Spike (Phase 08) v1.2
AWS auth per-run-rotated long-lived key (D-039 waiver) real OIDC federation (go-gitea/gitea#36988)
IAM minimal user acdl-spike-runner + scoped policy OIDC role + trust policy (no user, no key)
State backend S3 + DynamoDB single-region (us-east-1) multi-region
Secret storage gitignored .env.secrets + optional Gitea secret Gitea OIDC-issued web-identity token (no secret)