Files
acdl/terraform/bootstrap
Jon Chery 7eec07fc15 feat(P56): IAM re-bootstrap — policy extension + IAM_POLICY.md + baseline test
Vertical slice 1 of Phase 56 (REQ-116). Offline-testable deliverables
landed; the live IAM apply step is escalated (D-095) below.

terraform/bootstrap/spike_runner_policy.json — extended with the minimum
permissions to terraform apply + probe CAP-017..022:
- cloudfront:* (CAP-020 static-assets stack)
- wafv2:* (CAP-020 WAF ACL)
- lambda:* on function:acdl-* (CAP-018 contract-ingestor)
- dynamodb:* on acdl-contracts + acdl-change-requests (CAP-017)
- secretsmanager:GetSecretValue on secret:acdl/* (CAP-018 github-token)
- sns:* on acdl-* (CAP-017 acdl-sod-halt)
- ce:Get* (REQ-119 Cost Explorer read-only)
- kms:* (CAP-017 platform + per-stack CMKs)
- iam:CreateOpenIDConnectProvider + iam:CreateRole (CAP-022 OIDC re-create)

.ciagent/IAM_POLICY.md — new baseline document. Original grants
(v1.1–v1.10) + v1.11 grants table + least-privilege scoping notes +
OIDC act_runner role plan + D-095 escalation note.

tests/test_iam_policy_baseline.py — 15 tests. Asserts the required
actions are present per service group, Lambda scoped to acdl-*, CE
read-only, no iam:PassRole to Resource:*, DynamoDB acdl-contracts in
resource. Regression-testable: any future permission drift surfaces as
a test failure at milestone COMPLETE (D-091 gate).

Test results: 15/15 pass. Full offline suite 509/509 pass (pre-existing
test_seeded_registry_runs_and_reports_honest_status in
test_verify_regression_mode.py hangs without AWS creds — environmental,
not introduced here).

---ci---
project: acdl
phase: 56
milestone: v1.11
status: execute
escalation:
  type: deploy
  id: D-095
  reason: ACDL_BOOTSTRAP_AWS_* not set in the execution environment
  blocking: live IAM policy apply (aws iam put-user-policy) + OIDC role
    re-creation (CAP-022) — requires an admin AWS principal
  action_required: provide fresh ACDL_BOOTSTRAP_AWS_ACCESS_KEY_ID +
    ACDL_BOOTSTRAP_AWS_SECRET_ACCESS_KEY to the run environment, then
    re-invoke ciagent-run to resume Phase 56 live step
  fallback: none (D-095 confirmed: escalate to human, no silent fallback
    to the deck-marking path)
---/ci---
2026-07-28 12:44:31 +00:00
..

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.

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)