ADR-0014: A per-account seed, then everything through GitHub Actions#

Context#

The bootstrap layer (state bucket, GitHub OIDC provider, CI roles) used to be applied once by a person with local state, because it creates the things CI needs to authenticate at all. That made the most security-sensitive step the least reproducible one: it lived in someone's terminal and someone's local state file.

The goal is that every step that can be automated runs from this repository through GitHub Actions, so standing up a new account is a repeatable operation rather than a procedure, and that it works for any AWS account, whether or not it belongs to an AWS Organization.

Some first step cannot run in Actions: before anything is configured, a new account has no identity GitHub can federate into. The question is how small that step can be.

Decision#

Four phases. Only phase 0 is done by hand, once per account.

PhaseWhatHowOwner of the state
0. SeedGitHub OIDC provider, state bucket, testz-gha-bootstrap rolescripts/seed.sh applies terraform/seed with OpenTofu: in the seed-account workflow with a temporary user (ADR-0016), or from a person's machineS3, seed/terraform.tfstate (local on the very first run, then migrated)
1. Bootstraptestz-gha-{plan,apply,deploy} roles and the workload permissions boundarybootstrap-account workflowS3, bootstrap/terraform.tfstate
2. InfrastructureThe stackterraform-plan / terraform-apply / site-deployS3, testz/prod/terraform.tfstate
3. Go-liveNameservers and DS at the registrar, SNS confirmationOutside AWS; values published in the apply run summary—

Each phase only holds the power the next one needs:

  • The seed's bootstrap role trusts only the repository's bootstrap

environment. It can manage testz-gha-* roles and testz-* policies, write only the bootstrap/ state key, and cannot modify itself.

  • The apply role (phase 2) is denied any IAM action on testz-gha-*,

including the bootstrap role, and may write state only under testz/, so it cannot reach the state or the definition of the layer above it.

  • Nothing in Actions can change the seed. Changing it means re-running the

deploy by hand.

The workflows derive every ARN and the state bucket name from one repository secret, AWS_ACCOUNT_ID, which is the only value copied out of AWS.

AWS Organizations is optional. If the account is in an organization, phase 0 can sign in by switching into OrganizationAccountAccessRole from the management account. Nothing depends on it.

Alternatives considered#

Seed in CloudFormation. The first draft. CloudFormation keeps its own state, so it avoids the seed creating its own state bucket. It lost to a second tool and language in the repository; the OpenTofu seed handles the bootstrapping with one local-then-migrate run (ADR-0015).

Bootstrap everything from the organization's management account (a seed role there assuming OrganizationAccountAccessRole into members). Removes the per-account manual step, but ties every account to Organizations and gives one CI role administrator access to every member account. Not the foundation.

Access keys in a GitHub secret for the first run, deleted afterwards. Creates exactly the long-lived credential ADR-0006 rules out, if only for a while, and a forgotten deletion is silent.

Terraform bootstrap with local state, migrated into its own bucket. The original design. init -migrate-state makes the first run different from every later one and cannot run cleanly in a workflow.

An IAM user for the human operator (ADR-0013). Unnecessary once no person applies anything.

Consequences#

Positive: no IAM users and no long-lived credentials, for CI or people. A new account is: deploy the seed, set AWS_ACCOUNT_ID, run two workflows, do the registrar steps. Bootstrap state is durable and versioned instead of a local file, and changes to the CI roles go through the same reviewed path as everything else.

Negative: the seed's bootstrap role can write the apply role's policies, so it can grant anything inside the account — inherent in whatever creates the CI roles. Its only gate is the bootstrap environment. While the repository is private on GitHub Free that environment cannot require a reviewer, so anyone with write access who dispatches the workflow holds that power. Today that is one person; it is a reason to move to a public repository or a paid plan (ADR-0011) before anyone else gets write access. The seed's very first run keeps state on the operator's machine for a few minutes before migrating it.

Neutral: phase 0 is a manual step per account, deliberately: it is the one place a person with direct access to the account establishes trust in this repository.

Status notes#

  • 2026-11-24. One statement in Decision was not true of the account,

and one gate was weaker than it reads. The apply role "may write state only under testz/", but its stack bucket statement allows s3:Put* and s3:DeleteObject on testz-*/*, which also matches the bootstrap/ and seed/ keys. And the bootstrap environment that gates the bootstrap role is not bound to a branch: any branch whose workflow names it receives the role, as the seed run of 24 November did from a feature branch. ADR-0019 adds an explicit deny for the first and a ref condition binding the bootstrap role to main for the second. Both are written but not yet applied: the deny with the bootstrap layer, the condition with the next seed run (runbook).

  • 2026-11-25. Both are in force. The deny was applied by

bootstrap-account on 24 November. The bootstrap role's condition was added on 25 November in the IAM console, not by a seed run, matching the seed's code, so the next seed plan should show no change (see ADR-0016's status notes). Nothing in Actions can change the seed still holds.

Revisit when#

  • A second person gets write access, or the repository gains required

reviewers: add a reviewer to bootstrap and prod.

  • Accounts are created often enough that per-account phase 0 hurts: run the

seed from an account-vending pipeline.

  • GitHub changes its OIDC claim structure.

Built 2026-11-25 from commit 33bfabf6a27d4baeecf228c31bd5d636a3965070. This page was generated from the same source that provisions the infrastructure it describes.