Repository navigation
fix(iac/aws): bind rollback.yml jobs to dev/staging/prod, not <cloud>-<env>-rollback - #367
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: LeanerCloud/cloud-commitments-platform/.coderabbit.yaml Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (1)
Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour. 📝 WalkthroughWalkthroughThe rollback workflow now binds its AWS Lambda, AWS Fargate, GCP, and Azure jobs to the plain ChangesRollback environments
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Merge Risk: 🟡 Moderate · up to Until the separately applied AWS and Azure trust policies accept the new environment identities, rollback authentication can fail. Confirm the bootstrap re-apply before relying on the changed rollback workflow. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
…>-rollback
The four rollback jobs bound compound environment names
(aws-lambda-<env>-rollback, aws-fargate-<env>-rollback,
gcp-<env>-rollback, azure-<env>-rollback), producing the OIDC subject
repo:<org/repo>:environment:<name>. None of those compound names is in
any cloud's trust allowlist: AWS's role.tf sub list only has
ref:refs/heads/main plus plain environment:{dev,staging,prod}, and
Azure's federated credentials (sp.tf) only cover plain
dev/staging/prod. So configure-aws-credentials and azure/login failed
outright on every rollback attempt (AssumeRoleWithWebIdentity denied /
AADSTS70021 respectively) -- the rollback path has never been able to
authenticate, independent of anything this PR's sibling fixes touch.
GCP was unaffected: its trust condition checks repository and ref, not
sub, so the environment name was never load-bearing there.
Rebind all four jobs to the plain environment name
(${{ inputs.environment }}), reusing the dev/staging/prod
environments every deploy workflow already binds to and that AWS/Azure
already trust, per option 2 in the issue (the smaller of the two fixes
the issue lays out; option 1 would need 12 new environments and, for
Azure, 12 new federated credential resources, since Azure allows no
wildcards).
Tradeoff, called out in the workflow-level comment: a rollback now
shares its approval gate with the corresponding deploy environment
rather than having a distinct rollback-only reviewer set. This is a
policy call the issue leaves open; if rollback ever needs a separate
reviewer list, that is option 1, done later as its own change.
Not fixed here (separate issues): no environment in this repo has
protection rules yet (#141), and the live trust policies still need the
bootstrap re-apply from #2 before any of this authenticates against a
real cloud account.
Verified: actionlint (native v1.7.12, exit 0) and zizmor
(--offline --persona=pedantic --min-severity=medium, 0 findings) on
rollback.yml.
Closes #139
Co-Authored-By: claude-flow <ruv@ruv.net>
… fargate binding
Independent review caught three problems in the original rebind:
1. The workflow comment and PR body claimed AWS never trusted the
compound <cloud>-<env>-rollback subjects. False: role.tf:139-144
already allowlisted all six aws-{lambda,fargate}-<env>-rollback
subjects (added for #1648) -- only Azure's federated credentials
(sp.tf) lacked any compound-rollback entry, so rollback-azure was
the only job that actually failed OIDC auth (AADSTS70021) before
this fix. GCP was unaffected either way, since its trust condition
never checks sub. Rewrote the workflow-level comment in rollback.yml
to state this accurately instead of the blanket "no cloud trusted
these" claim.
2. Once every rollback job binds its deploy's own environment name
instead of a *-rollback suffix, nothing presents the six AWS
compound subjects any more. Deleted them from role.tf (and the
matching README table rows / count), rather than leaving unused
trust surface that reads as intentional.
3. rollback-aws-fargate was rebound to plain dev/staging/prod, but
deploy-aws-fargate.yml binds aws-fargate-<env> (already trusted,
role.tf) -- a different, already-existing environment. Rebound
rollback-aws-fargate to match its own deploy job instead of
Lambda's plain-name environment.
Also dropped the now-stale "rollback.yml -> azure-{dev,staging,prod}-
rollback" line from azure/ci-cd-permissions/variables.tf's
github_environments doc comment -- rollback-azure binds plain
dev/staging/prod now, which that variable's default already covers.
Verified: actionlint (native v1.7.12) and zizmor (0 findings) on
rollback.yml; terraform fmt/init -backend=false/validate/tflint clean
on both terraform/environments/{aws,azure}/ci-cd-permissions.
Co-Authored-By: claude-flow <ruv@ruv.net>
1a6cd00 to
dae3ced
Compare
… review Independent review caught two problems left over from #367's final shape: 1. The dev/staging/prod bullet had a garbled mid-sentence insertion ("deploy-aws-fargate's sibling compute platforms use their own names (below)") and, now that #367 rebinds rollback-aws-fargate to aws-fargate-<env> instead of plain dev/staging/prod, the "all four rollback.yml jobs" claim was also wrong -- only three of the four do. Rewrote the bullet to name the three rollback jobs that share this group and call out that rollback-aws-fargate pairs with deploy-aws-fargate.yml's own aws-fargate-<env> group instead. 2. The trust-allowlist note implied all three clouds gate environment names the same way via a "github_environments variable". Only Azure has one; AWS's trust list is a literal sub array inlined in role.tf, not a variable; GCP doesn't gate by environment/sub at all (ref-based only, per #141). Replaced the generic note with the three distinct mechanisms and where each one lives. Verified: markdownlint clean. Co-Authored-By: claude-flow <ruv@ruv.net>
|
Independent adversarial review (two rounds) + local verification: MERGE at dae3ced. Rollback jobs now bind the same environments their deploys use (dev/staging/prod; aws-fargate- for Fargate), which every cloud's trust already covers; the six orphaned aws-*-rollback subjects are removed from role.tf. Reconciled every role-to-assume job against role.tf: all presented subjects trusted, none of the removed ones presented. Bootstrap-only change, effective on the #2 re-apply. terraform/actionlint/zizmor clean; policy guard 40 passed; 25/25 checks. |
Summary
Rebinds
rollback.yml's four rollback jobs to the same environment nameeach job's corresponding deploy workflow already uses, instead of a
compound
<cloud>-<env>-rollbackname; deletes the AWS trust entries thatcompound naming needed and this rebind makes unused.
Root cause (corrected after independent review)
The original version of this PR incorrectly claimed no cloud trusted the
compound
<cloud>-<env>-rollbacksubjects. That was wrong for AWS.Re-verified against
terraform/environments/aws/ci-cd-permissions/role.tf:aws-{lambda,fargate}-<env>-rollbacksubjects (
role.tf:139-144, added for #1648).rollback-aws-lambdaandrollback-aws-fargatecould already authenticate before this PR.credentials (
terraform/environments/azure/ci-cd-permissions/sp.tf) onlycover
ref:refs/heads/mainplus plainenvironment:{dev,staging,prod}(via the
github_environmentfor_each).rollback-azureis the onlyjob that actually failed OIDC auth (
AADSTS70021) on every attempt.(
github_oidc.tf) checksrepository/ref, neversub, so theenvironment name was never load-bearing there.
So the real, narrower finding is:
rollback-azurehad a genuinepre-existing auth failure;
rollback-aws-lambda/rollback-aws-fargatedid not.
Fix
Rebind every rollback job to the same environment its own deploy job
uses, rather than a
-rollback-suffixed name:rollback-aws-lambda->${{ inputs.environment }}(plaindev/staging/prod, matchingdeploy-aws-lambda.yml)rollback-gcp->${{ inputs.environment }}(matchingdeploy-gcp.yml)rollback-azure->${{ inputs.environment }}(matchingdeploy-azure.yml) -- this is the actual authentication fixrollback-aws-fargate->aws-fargate-${{ inputs.environment }}(matching
deploy-aws-fargate.yml, not plaindev/staging/prod-- fixed after review; the first version of this PR bound it to the
Lambda environment name by mistake)
Deleted the six now-dead AWS trust entries (
role.tf:139-144) ratherthan leaving them as unused trust surface: once every rollback job binds
its deploy's own environment name, nothing presents
environment:aws-{lambda,fargate}-<env>-rollbackany more. Updatedrole.tf's README table and environment count (9, not 15) to match.Also dropped the now-stale
rollback.yml -> azure-{dev,staging,prod}- rollbackline from Azure'sgithub_environmentsdoc comment(
variables.tf) --rollback-azurebinds plaindev/staging/prodnow, already covered by that variable's default.
Option 1 from the issue (give rollback its own environment family
everywhere) would still need 12 more GitHub Environments and, for Azure
specifically, more federated credential resources (Azure allows no
wildcards). This PR stays with option 2 -- reuse what already exists and
is already trusted -- documented as a deliberate tradeoff in the
workflow-level comment:
rollback-aws-lambda,rollback-gcpandrollback-azurenow share their approval gate with the correspondingdeploy environment;
rollback-aws-fargatealready shared it withdeploy-aws-fargateeven before this PR.Regression test
No automated test applies: this is an OIDC trust-boundary binding with no
local harness that exercises a real
configure-aws-credentials/azure/loginexchange, and perWORKER_BRIEF.mdthis sandbox cannotdispatch a real rollback against cloud infrastructure. Verified the
corrected root cause structurally instead:
Confirmed via
git show <parent>:...that both the AWS trust entries andthe Azure gap predate this PR and this whole issue family.
Verification
Pre-commit's
actionlinthook (language: docker_image) was skippedlocally with
SKIP=actionlinton both commits because this host's Dockerdaemon is hung (per repo
CLAUDE.md); nativeactionlintwas run instead(above). CI's own (non-Docker)
actionlint/pre-commit jobs run for real onthis PR.
Related / not fixed here
the
environment:binding scopes the OIDC subject but is not yet anapproval gate in practice (sec(ci): deployment environments have no protection rules, so environment-bound credentialed jobs run unapproved #141, BLOCKED-HUMAN).
the bootstrap re-apply tracked in sec(iac): rename-proof OIDC deploy trust + branch-restricted environments for the split platform repo #2 before any of this authenticates
against a real account.
.github/workflows/README.md's "Set Up Environments" section is fixed indocs(ci): regenerate the environments list from actual environment: bindings #369, sequenced after this PR's final environment names.
Closes #139
Summary by CodeRabbit
dev,staging, orprodapproval gate, aligning rollback approvals with deployments.