Skip to content

feat(bootstrap): custom bootstrap template generation #123

@scottschreckengaust

Description

@scottschreckengaust

Parent

Sub-issue 3 of #120 (RFC: Least-privilege CDK bootstrap policies as code)

Branch strategy

feat/bootstrap-template → targets feat/bootstrap-policies

Estimated review time: ~30 min

Summary

Generate a custom CDK bootstrap CloudFormation template that replaces AdministratorAccess with the three IaCRole-ABCA policies, and adds version/hash outputs for preflight validation.

Deliverables

  • Create cdk/src/bootstrap/bootstrap-template.ts — programmatically generates the custom CF template:
    • Based on CDK's default bootstrap template structure
    • Substitutes AdministratorAccess on the CloudFormation execution role with the three managed policies
    • Adds CF outputs: BootstrapPolicyVersion, BootstrapPolicyHash
    • Retains all other default resources (S3 staging bucket, ECR repo, deploy/lookup/publishing roles)
  • Create cdk/test/bootstrap/bootstrap-template.test.ts:
    • Generated template is valid YAML/JSON
    • Execution role references exactly three managed policies (not AdministratorAccess)
    • BootstrapPolicyVersion and BootstrapPolicyHash outputs are present
    • All default bootstrap resources still exist
    • Template parameters match CDK bootstrap expectations
  • Generate cdk/bootstrap/bootstrap-template.yaml — the operator-consumable artifact
  • Add mise //cdk:bootstrap:generate task in cdk/mise.toml — regenerates all cdk/bootstrap/ artifacts
  • Add mise //cdk:bootstrap task — wraps cdk bootstrap --template cdk/bootstrap/bootstrap-template.yaml

Key design decisions

  • Template is generated (not hand-edited) so it stays in sync with policy source code
  • Uses CF pseudo-parameters (AWS::AccountId, AWS::Region) for account/region — no hardcoding
  • Managed policies are created inline in the template (not referencing external ARNs) — eliminates the "create policies first, then bootstrap" two-step
  • Qualifier remains hnb659fds (CDK default) for compatibility with existing deployments

Acceptance criteria

  • mise //cdk:bootstrap:generate produces a valid CF template
  • Template passes cfn-lint validation (if available)
  • Existing mise //cdk:synth and mise //cdk:test still pass (no regression)
  • An operator can bootstrap a fresh account with a single command: mise //cdk:bootstrap

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions