Skip to content

feat(s3): add OIDC auth via aws-role-arn, unify credentials - #4

Merged
igorjs merged 4 commits into
mainfrom
feat/enterprise-hardening-s4-oidc
Sep 7, 2026
Merged

igorjs merged 4 commits into
mainfrom
feat/enterprise-hardening-s4-oidc

Conversation

@igorjs

@igorjs igorjs commented Sep 4, 2026

Copy link
Copy Markdown
Member

Summary

Long-lived AWS keys in repo secrets are a standing credential risk, and GitHub's OIDC token lets a workflow assume an IAM role instead. This adds that path for the s3 backend, and along the way fixes a latent bug: three duplicated per-step env: blocks would have silently overridden OIDC-exported credentials with empty strings.

What Changed

  • New aws-role-arn and aws-role-session-name inputs select OIDC auth for backend: s3 via aws-actions/configure-aws-credentials, instead of static access-key-id/secret-access-key.
  • OIDC is additive, not a replacement. Setting aws-role-arn together with the static keys fails loud with a validation error instead of picking one silently.
  • r2 has no OIDC equivalent and stays static-key only.
  • Replaced the three duplicated per-step env: blocks on Init, Plan, and Apply with one unified credential-configuring step. The old per-step blocks would have re-set AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY to empty strings on every step, clobbering whatever OIDC had just exported.
  • Documented the OIDC setup in the README: the trust policy, the required permissions: id-token: write, and a minimal with: block, plus a commented-out OIDC alternative in the example workflow.

Notes for reviewers

  • During post-implementation review, this Segment's own design called for two regression tests that were missing from the first pass: a grep confirming no stale per-step credential env: blocks remain, and a grep confirming the OIDC step selects aws-actions/configure-aws-credentials. Both are now in tests/action-logic.sh.
  • This is Segment 4 of 6 of the enterprise-hardening plan, stacked on feat/enterprise-hardening-s3-policy-gate (PR feat: add policy-as-code gate at plan-time and apply-time #3, already open).

Related work

@igorjs
igorjs force-pushed the feat/enterprise-hardening-s3-policy-gate branch 2 times, most recently from a996500 to 5599882 Compare September 7, 2026 04:08
Adds aws-role-arn and aws-role-session-name inputs. access-key-id and
secret-access-key become input-level optional, with explicit bash-level
validation replacing the implicit GitHub Actions required check.

For backend s3, aws-role-arn selects OIDC auth mode; setting it alongside
either static key fails loud. Without aws-role-arn, both static keys are
required (static mode), matching prior implicit behavior but now explicit.

For backend r2, static keys remain unconditionally required now that the
input-level required: true is gone.

Adds an auth-mode output (oidc or static) for downstream consumption.

Signed-off-by: igorjs <2278164+igorjs@users.noreply.github.com>
Add a dedicated Configure credentials step branching on
steps.validate.outputs.auth-mode from WU-6: the OIDC branch invokes
aws-actions/configure-aws-credentials, the static branch exports
AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY via $GITHUB_ENV. Remove the
three duplicated per-step env blocks from Init, Plan, and Apply so
they no longer shadow the ambient credentials with empty strings
when running in OIDC mode.

Signed-off-by: igorjs <2278164+igorjs@users.noreply.github.com>
Add an OIDC for AWS S3 README section covering aws-role-arn/aws-role-session-name, the additive-not-replacement relationship with static keys, the loud validation error when both are set, a trust policy example, and the required id-token: write permission. Add matching rows to the Inputs table. Add a commented-out OIDC with:/permissions: variant to examples/plan-apply.yml for both the plan and apply jobs. Add a CHANGELOG entry under Unreleased.

Signed-off-by: igorjs <2278164+igorjs@users.noreply.github.com>
@igorjs
igorjs force-pushed the feat/enterprise-hardening-s4-oidc branch from 7ee0a2a to 73005b2 Compare September 7, 2026 04:11
@igorjs
igorjs changed the base branch from feat/enterprise-hardening-s3-policy-gate to main September 7, 2026 04:11
- Add AWS_SESSION_TOKEN to both policy-command credential-isolation
  unset calls, since OIDC auth also exports a live STS session token
- Reject aws-role-arn set together with backend r2 instead of
  silently ignoring it, matching the fail-loud-on-conflict philosophy
- Add an aws_role_arn param to resolve_backend and assert_backend_fails
  test helpers, with a new scenario covering the r2 rejection
- Update the policy-command regression test to require all three AWS
  credential variables in the unset call

Signed-off-by: igorjs <2278164+igorjs@users.noreply.github.com>
@igorjs
igorjs force-pushed the feat/enterprise-hardening-s4-oidc branch from 73005b2 to 208fdf5 Compare September 7, 2026 04:18
@igorjs
igorjs marked this pull request as ready for review September 7, 2026 04:18
@igorjs
igorjs merged commit 3e46003 into main Sep 7, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant