Skip to content

feat(bootstrap): policies as typed TypeScript with version and hash#158

Merged
scottschreckengaust merged 10 commits into
mainfrom
feat/bootstrap-policies
May 21, 2026
Merged

feat(bootstrap): policies as typed TypeScript with version and hash#158
scottschreckengaust merged 10 commits into
mainfrom
feat/bootstrap-policies

Conversation

@scottschreckengaust
Copy link
Copy Markdown
Contributor

Summary

Closes #122

Ports the three IaCRole-ABCA IAM policies from docs/design/DEPLOYMENT_ROLES.md into typed
TypeScript modules at cdk/src/bootstrap/policies/. Adds SHA256 hashing and semver versioning
for drift detection.

Stack position

PR 3 for #120 — least-privilege CDK bootstrap policies as code

Prior: ADR-002 documented the design rationale (PR #133, pending merge)

This PR: Policies as code with tests and audit artifacts

Next: Custom bootstrap template generation (#123)

Key decisions

Test plan

  • npx jest test/bootstrap/ passes (31 tests)
  • Golden-baseline test confirms action-for-action parity with DEPLOYMENT_ROLES.md
  • Each policy < 6,144 chars (IAM limit)
  • All SIDs globally unique across 3 policies
  • Hash is deterministic and snapshot-locked
  • tsc --noEmit compiles cleanly

References: RFC #120, ADR-002 (#133)

🤖 Generated with Claude Code

scottschreckengaust and others added 9 commits May 20, 2026 05:58
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t from code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@scottschreckengaust
Copy link
Copy Markdown
Contributor Author

#126 — has a detailed implementation note explaining the version-bump enforcement gap and how the preflight validator should close it.

Summary of the artifact management lifecycle:

Developer changes policy TS

CI fails (3 ways):
• snapshot mismatch (hash changed)
• artifact-sync test (committed files stale)
• golden-baseline test (if DEPLOYMENT_ROLES.md also needs updating)

Developer must:
1. Bump BOOTSTRAP_VERSION in version.ts
2. Run generate-bootstrap-artifacts.ts
3. Update snapshot (-u)
4. Commit all together

Operator pulls & deploys

Preflight (#126, future) compares deployed hash vs required hash
• Match → deploy proceeds
• Mismatch → "re-bootstrap required" + exact command

The version-bump itself remains a developer responsibility (enforced by review convention now, deploy-time gate in #126 later). The files exist to give
the preflight validator something to compare against the live CDKToolkit stack outputs.


the combination of two tests:

  1. artifact-sync.test.ts — asserts each committed JSON file (cdk/bootstrap/policies/infrastructure.json etc.) equals the live fn().toJSON() output. So TypeScript → JSON conversion is verified.
  2. artifact-sync.test.ts — asserts committed BOOTSTRAP_HASH equals computeBootstrapHash(), which itself is computed from the live allPolicies().map(p => p.toJSON()) output. So the hash is verified against the actual policy content.

The chain is:

TypeScript policies (source of truth)
↓ toJSON()
Live PolicyDocument objects
↓ compared by artifact-sync test
Committed JSON files (must match)
↓ SHA256 of serialized toJSON()
Computed hash
↓ compared by artifact-sync test
Committed BOOTSTRAP_HASH file (must match)

If any link breaks — TypeScript changes, JSON stale, hash stale — the test fails. The golden-baseline test separately verifies the TypeScript matches DEPLOYMENT_ROLES.md, closing the full loop from documentation → code → artifacts → hash.

@scottschreckengaust scottschreckengaust marked this pull request as ready for review May 20, 2026 15:27
@scottschreckengaust scottschreckengaust requested a review from a team as a code owner May 20, 2026 15:27
@scottschreckengaust scottschreckengaust added this pull request to the merge queue May 21, 2026
Merged via the queue into main with commit 90a6580 May 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(bootstrap): policies as typed TypeScript with version and hash

2 participants