Repository navigation
feat(infra): make terraform applies unattended on merge to main - #355
Merged
Merged
Conversation
Operator decision: merge to `main` is the trigger and the only trigger. The
required-reviewer gate on `infra-apply-{core,dev,prod}` is removed, so §14.2
reads literally — plan on the PR, apply on merge, no click in between.
The environments themselves are kept. Without reviewers they still give each env
its own deployment history, and `protected_branches: true` on each means only
`main` can deploy to them regardless of what a workflow file claims.
## What now guards an apply, stated honestly
Nothing else does. `er-ci-tf-apply` holds AdministratorAccess, and §8.2's two
prod deny statements ride the *permission sets* — so they constrain humans, not
this role. That section already says the apply role "walks through the guardrail
legitimately" and therefore that "its trust policy is part of this claim".
With the gate gone, that trust condition — `sub` pinned to `refs/heads/main` —
plus branch protection and PR review IS the entire control. The `plan` tier is
where a human sees the diff, and it is now the ONLY place a human sees it before
infrastructure changes.
That matters most for prod, which is unprovisioned: `plan (prod)` currently
reports **61 resources to add**, including an RDS cluster, two instances, EFS
and security groups. A merged PR touching `infra/terraform/envs/prod` provisions
production and starts that bill, with no approval step behind it. That is the
intended behaviour now, and the plan output on the PR is the place to catch it.
## A consequence I had previously waved away
§14.2's chained **prod-scoped** apply role — whose trust names the CI apply role
plus `ProdAdmin` as break-glass — is still not built. Two commits ago I
described that gap as "covered by the required-reviewer GitHub environment". It
is not covered any more, because that environment no longer requires anyone.
So it goes from nice-to-have to the only remaining defence-in-depth for prod,
and it should land before prod carries data. Recorded in ci-terraform.tf, the
workflow header and roadmap 0.5b rather than left as a note in a merged PR
nobody re-reads.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Nov 1, 2026
…sed) (#363) This file has carried a "NOT built yet" note about §14.2's prod-scoped apply role since the plan/apply gate landed, and the note's premise went stale: it said the gap was "briefly covered by a required-reviewer environment", which stopped requiring anyone in #355, and prod has held an Aurora cluster since #352. So the only thing between a merge and a production teardown has been branch protection plus the destroy guard. `er-ci-tf-apply-prod`: AdministratorAccess, reachable from exactly two principals. **What the hop buys, narrowly stated**, because overclaiming it would be worse than not having it: 1. Auditability — a prod write becomes a distinct `AssumeRole` into a prod-named role in CloudTrail instead of being indistinguishable from a dev write by the same principal, and the chained session carries the GitHub session tags (Repository, Workflow, Actor, Commit, Branch), so the trail records who merged what. 2. No *accidental* prod apply from the non-prod path, once the companion PR denies `er-ci-tf-apply` the prod state object. 3. A break-glass path with the same permissions CI uses, so a human recovering prod is not improvising a different identity. **What it does not buy:** containment of a compromised `er-ci-tf-apply`. That role can assume this one — that is the design — so anyone holding it reaches prod through the front door. The control there is still its own `main`-only trust policy plus branch protection. AdministratorAccess for a sharper reason than the apply role's: narrowing it would buy nothing, because both principals that can reach it already hold AdministratorAccess. A tighter policy would only block Terraform, never an actor, while adding the mid-apply AccessDenied failure mode. **`sts:TagSession` is in the trust policy and is load-bearing.** Read from configure-aws-credentials' own source at the SHA this repo pins: both web-identity paths `delete params.Tags`, which is why no other role here needs it — but role CHAINING takes the plain `AssumeRole` path, which keeps them. Without this grant the prod apply would have failed on an AccessDenied for TagSession with nothing in the diff explaining it, the same shape as the three bugs #354 found. Allowing it is also the better end of the trade: `role-skip-session-tagging: true` would have worked and thrown away the tags that make reason 1 true. **ProdAdmin is trusted by pattern, not by ARN.** `envs/prod/eks.tf` hardcodes today's `AWSReservedSSO_ProdAdmin_<hash>`, which is fine for an EKS access entry and wrong for a trust policy: IAM resolves a principal ARN to the role's unique id on write, so once the permission set is recreated the policy holds a dangling id. Account root plus an `ArnLike` on the caller's own ARN survives that, and is not "anyone in the account" — the effective set is principals matching a ProdAdmin SSO session that also hold `sts:AssumeRole`. `PlatformAdmin` does not match; neither does the `er-dev-builder` key. **Nothing uses it yet, on purpose.** The chaining step and the companion deny land separately, because `apply (core)` creates this role and `apply (prod)` would consume it in the same run. They do run in that order today — measured core → dev → prod, strictly sequential under `max-parallel: 1` — but GitHub documents no ordering guarantee for a matrix, and resting a prod apply on undocumented ordering is the #358 trap again. Split, it is order-independent. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Operator decision: merge to
mainis the trigger and the only trigger. Therequired-reviewer gate on
infra-apply-{core,dev,prod}is removed, so §14.2reads literally — plan on the PR, apply on merge, no click in between.
The environments themselves are kept. Without reviewers they still give each env
its own deployment history, and
protected_branches: trueon each means onlymaincan deploy to them regardless of what a workflow file claims.What now guards an apply, stated honestly
Nothing else does.
er-ci-tf-applyholds AdministratorAccess, and §8.2's twoprod deny statements ride the permission sets — so they constrain humans, not
this role. That section already says the apply role "walks through the guardrail
legitimately" and therefore that "its trust policy is part of this claim".
With the gate gone, that trust condition —
subpinned torefs/heads/main—plus branch protection and PR review IS the entire control. The
plantier iswhere a human sees the diff, and it is now the ONLY place a human sees it before
infrastructure changes.
That matters most for prod, which is unprovisioned:
plan (prod)currentlyreports 61 resources to add, including an RDS cluster, two instances, EFS
and security groups. A merged PR touching
infra/terraform/envs/prodprovisionsproduction and starts that bill, with no approval step behind it. That is the
intended behaviour now, and the plan output on the PR is the place to catch it.
A consequence I had previously waved away
§14.2's chained prod-scoped apply role — whose trust names the CI apply role
plus
ProdAdminas break-glass — is still not built. Two commits ago Idescribed that gap as "covered by the required-reviewer GitHub environment". It
is not covered any more, because that environment no longer requires anyone.
So it goes from nice-to-have to the only remaining defence-in-depth for prod,
and it should land before prod carries data. Recorded in ci-terraform.tf, the
workflow header and roadmap 0.5b rather than left as a note in a merged PR
nobody re-reads.
Co-Authored-By: Claude Opus 5 (1M context) [email protected]
🤖 Generated with Claude Code