Repository navigation
fix(iam): accept GitHub immutable OIDC subjects in CI trust policies - #168
Merged
Merged
Conversation
Repos created after GitHub enabled immutable subjects get sub claims like repo:javaBin@95047/<repo>@<repo_id>:..., which repo:javaBin/*:* never matches, so AssumeRoleWithWebIdentity fails (seen on 2027.javazone.no). Allow the org-ID-pinned form on the app-broker, override-approver and apply-gate roles. The broker and apply-gate Lambdas check the `repository` claim, not `sub`, so they need no change. slack_alert parses `sub` for attribution and now strips the IDs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Terraform Plan🚧 Changes detected — Plan: 0 to add, 6 to change, 0 to destroy. Plan outputLLM ReviewRisk: 🟡 MEDIUM Plan updates 6 existing resources (0 add, 0 destroy): widens GitHub OIDC trust on three CI IAM roles to also accept repo:javaBin@95047/*, changes the Google identity provider authorize URL to restrict to the java.no domain, and redeploys two Lambda functions with new code.
|
Alexanderamiri
added a commit
that referenced
this pull request
Oct 31, 2026
…nd ci-registry (#178) ## Problem PR #168 made the org-wide CI roles accept GitHub's immutable OIDC subject (`repo:javaBin@95047/<repo>@<repo_id>:...`). The platform and registry roles were not changed and still match only the legacy subject: - `javabin-ci-infra-plan`: `repo:javaBin/platform:*` - `javabin-ci-infra`: `repo:javaBin/platform:ref:refs/heads/main` / `:environment:production` - `javabin-ci-registry`: `repo:javaBin/registry:ref:refs/heads/main` Both repos use the legacy format today (`use_immutable_subject: false` according to `gh api repos/javaBin/{platform,registry}/actions/oidc/customization/sub`). If either repo opts in, or is ever recreated (new repos can't opt out), platform plan/apply and team provisioning stop with `Not authorized to perform sts:AssumeRoleWithWebIdentity`. ## Change - New `github_platform_repo_id` (default `1175354559`) and `github_registry_repo_id` (default `1175355770`) variables in `iam/variables.tf`, from `gh api repos/javaBin/<repo> --jq .id`. - Each of the three roles now accepts the legacy subject and the immutable one. The immutable subject is pinned to the org ID and the exact repo ID, and keeps the same ref/environment restriction. The `job_workflow_ref` pin on `ci-infra` is unchanged. - `docs/platform-modules.md` describes the two subject formats and where the IDs are pinned. I also searched the rest of the repo (workflows, scripts, Lambdas, `terraform/org`) for code that parses or matches `sub`. Nothing else needs a change. `slack_alert` already strips the IDs (#168), and `ci_broker`/`apply_gate` (`shared/github_oidc.py`) check the `repository_owner`, `repository` and `job_workflow_ref` claims, not `sub`. The other `"sub"` hits are Google service-account JWTs and Cognito, which have nothing to do with GitHub OIDC. ## Verification - `terraform fmt -recursive -check` and `terraform validate` in `terraform/platform` pass. - A read-only targeted plan (`-lock=false`, targeting the three roles) shows `0 to add, 3 to change, 0 to destroy`. The only change is the `sub` condition, which becomes a list with the legacy and the immutable form, for example `repo:javaBin@95047/platform@1175354559:*`. - `python3 -m unittest discover -s terraform/lambda-src/tests` passes (no Lambda changes). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem
2027.javazone.no(team javazoneweb) fails tf-plan withNot authorized to perform sts:AssumeRoleWithWebIdentity. The repo was created 2026-10-26 and hasuse_immutable_subject: true, so its sub claim isrepo:javaBin@95047/2027.javazone.no@1433986972:.... The trust policies only allowrepo:javaBin/*:*. GitHub won't let the repo opt out.Change
ci_app_broker,ci_override_approverandci_apply_gatenow also acceptrepo:javaBin@95047/*:*, pinned to the org ID (newgithub_org_idvariable, default95047).slack_alertstrips the@<id>parts when it parsessubfor CI attribution, and a test covers it.repositoryclaim, notsub, so they need no change.Verification
python3 -m unittest discover -s terraform/lambda-src/tests: 159 passedterraform validatepasses. A local targeted plan updates the three roles in place. The local plan also showed javazoneweb destroys, but only because it had noregistered-teams.auto.tfvars, which CI syncs from the org.🤖 Generated with Claude Code