Repository navigation
feat(infra): §14.2's prod-scoped apply role (the role only, not yet used) - #363
Merged
Merged
Conversation
…sed) 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: Claude Opus 5 (1M context) <[email protected]>
Contributor
terraform plan
core — 2 to add, 0 to changemodule.identity_center.data.aws_ssoadmin_instances.this: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Read complete after 0s [id=2883378100]
module.github_oidc.data.aws_iam_policy_document.trust: Reading...
module.github_oidc.data.aws_iam_policy_document.trust: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.sccache_read: Reading...
data.aws_iam_policy_document.audit_bucket: Reading...
data.aws_iam_policy_document.sccache_read: Read complete after 0s [id=2701062528]
data.aws_iam_policy_document.cur_delivery: Reading...
data.aws_iam_policy_document.sccache_trust_write: Reading...
data.aws_iam_policy_document.sccache_write: Reading...
data.aws_iam_policy_document.audit_bucket: Read complete after 0s [id=3031279952]
data.aws_iam_policy_document.cur_delivery: Read complete after 0s [id=2207400467]
data.aws_iam_policy_document.ci_tf_apply_trust: Reading...
data.aws_iam_policy_document.sccache_write: Read complete after 0s [id=786296009]
data.aws_iam_policy_document.sccache_trust_write: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.sccache_trust_read: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_trust: Read complete after 0s [id=2538345208]
data.aws_iam_policy_document.config_bucket: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.sccache_trust_read: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.config_bucket: Read complete after 0s [id=4067691321]
module.github_oidc.data.aws_iam_policy_document.push: Reading...
module.github_oidc.data.aws_iam_policy_document.push: Read complete after 0s [id=3422899916]
module.identity_center.data.aws_ssoadmin_instances.this: Read complete after 0s [id=us-east-2]
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Read complete after 0s [id=3513372776]
module.identity_center.data.aws_identitystore_user.admin: Reading...
module.identity_center.data.aws_identitystore_user.admin: Read complete after 0s [id=b17b2500-e0b1-7046-405b-23c088cf392b]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# aws_iam_role.ci_tf_apply_prod will be created
+ resource "aws_iam_role" "ci_tf_apply_prod" {
+ arn = (known after apply)
+ assume_role_policy = jsonencode(
{
+ Statement = [
+ {
+ Action = [
+ "sts:TagSession",
+ "sts:AssumeRole",
]
+ Effect = "Allow"
+ Principal = {
+ AWS = "arn:aws:iam::797781631727:role/er-ci-tf-apply"
}
+ Sid = "CiApplyRoleChain"
},
+ {
+ Action = "sts:AssumeRole"
+ Condition = {
+ ArnLike = {
+ "aws:PrincipalArn" = "arn:aws:iam::797781631727:role/aws-reserved/sso.amazonaws.com/*/AWSReservedSSO_ProdAdmin_*"
}
}
+ Effect = "Allow"
+ Principal = {
+ AWS = "arn:aws:iam::797781631727:root"
}
+ Sid = "ProdAdminBreakGlass"
},
]
+ Version = "2012-10-17"
}
)
+ create_date = (known after apply)
+ force_detach_policies = false
+ id = (known after apply)
+ managed_policy_arns = (known after apply)
+ max_session_duration = 3600
+ name = "er-ci-tf-apply-prod"
+ name_prefix = (known after apply)
+ path = "/"
+ tags_all = {
+ "Environment" = "core"
+ "ManagedBy" = "terraform"
+ "Project" = "entity-resolution"
}
+ unique_id = (known after apply)
+ inline_policy (known after apply)
}
# aws_iam_role_policy_attachment.ci_tf_apply_prod_admin will be created
+ resource "aws_iam_role_policy_attachment" "ci_tf_apply_prod_admin" {
+ id = (known after apply)
+ policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
+ role = "er-ci-tf-apply-prod"
}
Plan: 2 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ ci_tf_apply_prod_role_arn = (known after apply)
|
athvin
added a commit
that referenced
this pull request
Nov 1, 2026
…the old path (#364) The companion to #363, which created `er-ci-tf-apply-prod` but left it unused. This makes `envs/prod` actually apply through it, and — the part that matters — makes that the only path Terraform has. **`er-ci-tf-apply` is denied the prod state object.** An explicit Deny overrides its AdministratorAccess, scoped to `envs/prod.tfstate` and `envs/prod.tfstate.tflock` (`use_lockfile = true` makes taking the lock a write of its own). Scoping it to the STATE rather than to prod resource types is the trick. Enumerating would be the instinct and does not work: the prod stack manages a VPC and its subnets, NAT, EKS, Aurora, EFS, S3 and KMS, while §8.2's PlatformAdmin guard — which does enumerate — covers only the destructive verbs on five services. Copying that shape here would leave the apply role able to reconfigure prod's network while unable to delete its database, which is not a boundary anyone can reason about. Terraform cannot apply a stack whose state it cannot read, so two objects deny the whole stack with nothing to keep in step as prod grows. **What this is:** the thing that stops the hop being decorative. Without the deny, deleting the chaining step would silently restore a direct prod apply and nothing would report it. With it, the audited hop is the only route and its absence fails loudly at `terraform init`. **What this is not:** containment. `er-ci-tf-apply` holds AdministratorAccess and may assume the prod role — by design — so it reaches prod deliberately. What is ruled out is the accident: a matrix entry, a `-chdir`, or a copied job pointed at `envs/prod` from the non-prod identity now fails on state access instead of reconfiguring production. The workflow gains one step, `if: matrix.key == 'prod'`, using `role-chaining: true` so the action reuses the OIDC credentials rather than exchanging again — which is why the prod role's trust names `er-ci-tf-apply` instead of the OIDC provider. Session tags survive this path (the web-identity paths drop them, plain `AssumeRole` does not), so CloudTrail records the actor, commit and branch behind every prod write. STS caps a chained session at one hour, which is this job's timeout anyway. §14.2 and the infra-platform skill now describe three roles rather than two, with the break-glass procedure spelled out: assume `ProdAdmin`, then `sts assume-role` into the same prod role CI uses, rather than improvising an identity while recovering production. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
This was referenced Nov 1, 2026
athvin
added a commit
that referenced
this pull request
Nov 1, 2026
… red on it (#368) #367's `apply (core)` failed and `main` is red. The drift role was never created, so nothing partially applied and nothing needs cleaning up — the next apply retries from a clean state. AWS rejected the trust policy: MalformedPolicyDocument: Trust policy with trusted principal …oidc-provider/token.actions.githubusercontent.com must evaluate, using StringEquals, StringLike or StringEqualsIgnoreCase, …:sub or …:job_workflow_ref which is not scoped to all. I had written `job_workflow_ref` as `StringLike` on `*/.github/workflows/drift.yml@refs/heads/main`, with the leading wildcard deliberately hedging whether that claim carries the customised immutable prefix this repo's `sub` uses. Two things I had wrong: - a pattern that STARTS with `*` is "scoped to all" to that validator, and - it refuses on any such condition rather than being satisfied by the exact `sub` StringEquals sitting beside it, which is what I assumed the message's "sub **or** job_workflow_ref" wording allowed. So the uncertainty has to be resolved rather than wildcarded. Both candidate formats are now listed as literals under `StringEquals`, which ORs them: the documented `OWNER/REPO/.github/workflows/FILE@REF`, and the same claim with the immutable ids in case it carries them. That is strictly better than the wildcard was — no pattern to widen, and if GitHub ever changes the format the role stops being assumable LOUDLY at `AssumeRoleWithWebIdentity` rather than quietly matching more than intended. Worth recording why the second condition not pinning the repository costs nothing: `sub` already pins owner and repository by numeric id, immutably. `job_workflow_ref` only has to answer "which workflow file, on which ref". §14.2 and the infra-platform skill described the wildcard form, so both are corrected, and the skill now states the rule as AWS enforces it rather than as a preference — an exact match is not a style choice here, a wildcard-leading one fails `CreateRole`. This is the fourth bug in this series that only a real apply could find, after the environment-vs-ref `sub` in #356, the two reads `ReadOnlyAccess` omits in #354, and `sts:TagSession` on a chained role in #363. The pattern is consistent: IAM trust policies and OIDC claims are not verifiable by `terraform validate`, and every one of them has cost exactly one red run. Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Nov 1, 2026
…y noise (#369) * fix(infra): AWS refuses a wildcard-leading job_workflow_ref — main is red on it #367's `apply (core)` failed and `main` is red. The drift role was never created, so nothing partially applied and nothing needs cleaning up — the next apply retries from a clean state. AWS rejected the trust policy: MalformedPolicyDocument: Trust policy with trusted principal …oidc-provider/token.actions.githubusercontent.com must evaluate, using StringEquals, StringLike or StringEqualsIgnoreCase, …:sub or …:job_workflow_ref which is not scoped to all. I had written `job_workflow_ref` as `StringLike` on `*/.github/workflows/drift.yml@refs/heads/main`, with the leading wildcard deliberately hedging whether that claim carries the customised immutable prefix this repo's `sub` uses. Two things I had wrong: - a pattern that STARTS with `*` is "scoped to all" to that validator, and - it refuses on any such condition rather than being satisfied by the exact `sub` StringEquals sitting beside it, which is what I assumed the message's "sub **or** job_workflow_ref" wording allowed. So the uncertainty has to be resolved rather than wildcarded. Both candidate formats are now listed as literals under `StringEquals`, which ORs them: the documented `OWNER/REPO/.github/workflows/FILE@REF`, and the same claim with the immutable ids in case it carries them. That is strictly better than the wildcard was — no pattern to widen, and if GitHub ever changes the format the role stops being assumable LOUDLY at `AssumeRoleWithWebIdentity` rather than quietly matching more than intended. Worth recording why the second condition not pinning the repository costs nothing: `sub` already pins owner and repository by numeric id, immutably. `job_workflow_ref` only has to answer "which workflow file, on which ref". §14.2 and the infra-platform skill described the wildcard form, so both are corrected, and the skill now states the rule as AWS enforces it rather than as a preference — an exact match is not a style choice here, a wildcard-leading one fails `CreateRole`. This is the fourth bug in this series that only a real apply could find, after the environment-vs-ref `sub` in #356, the two reads `ReadOnlyAccess` omits in #354, and `sts:TagSession` on a chained role in #363. The pattern is consistent: IAM trust policies and OIDC claims are not verifiable by `terraform validate`, and every one of them has cost exactly one red run. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * fix(infra): the first drift run measured the signal, and it was mostly noise `drift.yml` ran for the first time (41280636155) and failed on all four stacks. The trust policy worked — `Authenticated as assumedRoleId AROA3TP35ULXVJ57LM6EF` — so #368 was right. Everything after it was wrong, in three separate ways, and none of them was findable without running it. **1. `-detailed-exitcode` is not a drift signal.** `dev` and `prod` both printed "found no differences" and both exited 2. A refresh-only plan has something to persist almost by construction. Treating 2 as drift would have turned the schedule red every single day — the alarm fatigue I argued against in the very commit that introduced it. **2. The text sentinel is not one either.** "Objects have changed outside of Terraform" fired on `core` and `state-backend`. Neither was drift: state-backend aws_kms_key.state — `tags` appearing as {} where state holds null aws_s3_bucket.state — `tags`, plus `policy` reporting what a SEPARATE aws_s3_bucket_policy resource manages core aws_iam_role.ci_tf_drift — `managed_policy_arns` reporting what a SEPARATE aws_iam_role_policy_attachment manages Same shape each time: an attribute the provider computes from something Terraform manages elsewhere, or a null/empty normalisation. And `state-backend` makes it permanent rather than transient — CI plans that stack and never applies it, so nothing reconciles its state snapshot and it would have reported drift forever. So drift is now decided PER ATTRIBUTE by `scripts/ci/tf-drift-classify.sh`, from the plan JSON, against an ignore list where every entry was observed in that run. Extend it the same way — from evidence — never pre-emptively, because each entry is a place real drift can hide. The ignored entries are still printed, so they do not vanish. `policy` is ignored only on `aws_s3_bucket`, not globally: a real change to an `aws_iam_role_policy` document must stay loud. There is a test for exactly that. Nothing from the JSON is printed but addresses and attribute NAMES — the same rule the apply tier follows, for the same reason. `driftplan` and `plan.json` carry values in cleartext and there is deliberately no upload step in the workflow. **3. A third missing read: `bcm-data-exports:ListTagsForResource`.** Refreshing the CUR export reads its tags as a separate call and `ReadOnlyAccess` omits that too. #354 found `GetExport` by failing on it and then switched the plan tier to `-refresh=false` — so until this workflow existed nothing had ever COMPLETED a full refresh, and this call had never been reached. A fourth may appear with the next resource type. Also recorded, because "read-only role" reads safer than it is: the drift role's `er/*` secret scope reaches `er/dev/shared/builder`, the never-expiring AdministratorAccess key. It does not widen anything — reaching this role takes a merge to `main`, and anyone who can merge can already use `er-ci-tf-apply`, which is admin outright — so the grant sits inside an existing boundary. The policy is deliberately not contorted to exclude it, because the dev stack stores that key in a `secretsmanager_secret_version` and excluding it would fail every dev refresh. The thing to fix is the key. The helper suite is now 41 assertions, and the new ten are mutation-checked: emptying the ignore list, ignoring `policy` globally, making the classifier unable to report drift, and letting a parse failure pass each turn it red. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
athvin
pushed a commit
that referenced
this pull request
Nov 1, 2026
… sightings Second real drift run (41283281935) after #369. `dev` and `prod` went GREEN — the `-detailed-exitcode` false positives are gone, which was the main thing #369 fixed. `state-backend` and `core` still failed, and the classifier is why that was useful rather than opaque: it reported exactly which attributes it ignored and which it did not. state-backend ignored aws_kms_key.state [tags] real aws_s3_bucket.state [server_side_encryption_configuration, versioning] core real aws_iam_role.ci_tf_drift [inline_policy] All three are the SAME class as the ones #369 already ignored — an attribute the provider deprecated in favour of a separate resource and now computes from it. Run 1's truncated text output had simply hidden them behind the `# ... has changed` headline. So the list stops being a record of sightings and becomes a rule: ignore an attribute on a type when a SIBLING RESOURCE owns it. What makes that safe rather than convenient is that nothing hides — turn bucket versioning off in the console and `aws_s3_bucket_versioning` drifts; the deprecated `aws_s3_bucket.versioning` mirror saying so too is duplicate noise, not the signal. That rule is also the boundary, and it is the reason the entries stay type-scoped. `policy` is ignored on `aws_s3_bucket` and nowhere else, because a real change to an `aws_iam_role_policy` document must stay loud. `managed_policy_arns` moved out of the ignore-anywhere list for the same reason. With the rule stated, the `aws_s3_bucket` family is listed in full rather than one sighting at a time — every one of those is owned by an `aws_s3_bucket_*` resource — so this does not need a third round. 42 assertions now, and the two entries run 2 surfaced are mutation-checked: removing `aws_s3_bucket:versioning` and `aws_iam_role:inline_policy` turns the suite red on "deprecated sibling mirrors are NOT drift". Also corrected the test file's own header, which still claimed three helpers and that §14.2's prod-scoped apply role was unbuilt — it has been since #363/#364 — and now states the opposite risk the classifier carries: an over-broad ignore entry retires drift detection while leaving the workflow in the tree. One process note, since it cost a redo: `reset --hard` on uncommitted work loses it, and the repo's own memory says to check `git status` before any git operation here. I did not, and rewrote these two edits. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Nov 1, 2026
… sightings (#370) Second real drift run (41283281935) after #369. `dev` and `prod` went GREEN — the `-detailed-exitcode` false positives are gone, which was the main thing #369 fixed. `state-backend` and `core` still failed, and the classifier is why that was useful rather than opaque: it reported exactly which attributes it ignored and which it did not. state-backend ignored aws_kms_key.state [tags] real aws_s3_bucket.state [server_side_encryption_configuration, versioning] core real aws_iam_role.ci_tf_drift [inline_policy] All three are the SAME class as the ones #369 already ignored — an attribute the provider deprecated in favour of a separate resource and now computes from it. Run 1's truncated text output had simply hidden them behind the `# ... has changed` headline. So the list stops being a record of sightings and becomes a rule: ignore an attribute on a type when a SIBLING RESOURCE owns it. What makes that safe rather than convenient is that nothing hides — turn bucket versioning off in the console and `aws_s3_bucket_versioning` drifts; the deprecated `aws_s3_bucket.versioning` mirror saying so too is duplicate noise, not the signal. That rule is also the boundary, and it is the reason the entries stay type-scoped. `policy` is ignored on `aws_s3_bucket` and nowhere else, because a real change to an `aws_iam_role_policy` document must stay loud. `managed_policy_arns` moved out of the ignore-anywhere list for the same reason. With the rule stated, the `aws_s3_bucket` family is listed in full rather than one sighting at a time — every one of those is owned by an `aws_s3_bucket_*` resource — so this does not need a third round. 42 assertions now, and the two entries run 2 surfaced are mutation-checked: removing `aws_s3_bucket:versioning` and `aws_iam_role:inline_policy` turns the suite red on "deprecated sibling mirrors are NOT drift". Also corrected the test file's own header, which still claimed three helpers and that §14.2's prod-scoped apply role was unbuilt — it has been since #363/#364 — and now states the opposite risk the classifier carries: an over-broad ignore entry retires drift detection while leaving the workflow in the tree. One process note, since it cost a redo: `reset --hard` on uncommitted work loses it, and the repo's own memory says to check `git status` before any git operation here. I did not, and rewrote these two edits. 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.
ci-terraform.tfhas 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 #360's destroy guard.er-ci-tf-apply-prod— AdministratorAccess, reachable from exactly two principals.er-ci-tf-planer-ci-tf-applymainonly, via the threeinfra-apply-*environmentscore,dever-ci-tf-apply-proder-ci-tf-apply, orProdAdminas break-glassprodWhat the hop buys, narrowly stated
Overclaiming this would be worse than not having it, so:
AssumeRoleinto 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. §8.6 can alert on it.er-ci-tf-applythe prod state object.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 ownmain-only trust policy plus branch protection. Please read this role as making the prod write legible, not as a boundary against the apply role.AdministratorAccess again, for a sharper reason than the apply role's: narrowing it would buy nothing, because both principals that can reach it already hold AdministratorAccess (
er-ci-tf-applyby attachment,ProdAdminbyaws_ssoadmin_managed_policy_attachment.prod_admin). A tighter policy would only block Terraform, never an actor, while adding the mid-apply AccessDenied failure mode the existing comment rejects.Two details that would each have cost a failed prod apply
sts:TagSessionis in the trust policy and is load-bearing. Read from configure-aws-credentials' own source at the SHA this repo pins (src/assumeRole.ts): both web-identity paths calldelete params.Tags, which is why no other role here needs this grant — but role chaining takes the plainAssumeRolepath, which keeps them. Without it the prod apply would fail on an AccessDenied forTagSessionwith nothing in the diff explaining why, the same shape as the three bugs #354 found on real runs. Allowing it is also the better end of the trade:role-skip-session-tagging: truewould have worked and thrown away the tags that make reason 1 above true.ProdAdmin is trusted by pattern, not by ARN.
envs/prod/eks.tfhardcodes today'sAWSReservedSSO_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 — any change to it does that — the policy holds a dangling id that can't be read back as a name. Account root plus anArnLikeon the caller's own ARN survives that.That form is not "anyone in the account": a root principal delegates to identity policies and the condition is evaluated against the caller's ARN, so the effective set is exactly principals matching a ProdAdmin SSO session that also hold
sts:AssumeRole.PlatformAdmindoes not match the pattern; neither does theer-dev-builderuser's key.Nothing uses it yet, on purpose
The chaining step and the companion deny land in a separate PR, because
apply (core)creates this role andapply (prod)would consume it in the same run. They do run in that order today — measured core → dev → prod, strictly sequential undermax-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's order-independent.So this PR's
plan (core)should show 2 to add (the role and its policy attachment) and 0 to destroy, andplan (prod)should be empty.Verification
terraform fmt -check -recursive, offlinevalidateonenvs/core.CiApplyRoleChain,ProdAdminBreakGlass),sts:TagSessionon the chaining statement only,ArnLikeonaws:PrincipalArnfor the break-glass one.scripts/skills-check.sh allgreen — and it earned its keep here: theaws-account-operationsfootprint reference countsresource "aws_*"blocks, so it went red on 14→15aws_iam_roleand 6→7aws_iam_role_policy_attachmentuntil the regenerated count was committed.scripts/ci/tf-helpers-test.shgreen (31 assertions).🤖 Generated with Claude Code