← Back to portfolio
02

GitHub Actions × AWS via OIDC

Replaced long-lived AWS access keys in GitHub with short-lived credentials using OpenID Connect and IAM role assumption — no secrets to rotate in the repository.

OIDCIAMActionsSecurity

Problem

Storing AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in GitHub secrets works but creates credential sprawl, rotation overhead, and a larger blast radius if a secret leaks.

Solution

GitHub Actions requests a JWT from GitHub's OIDC provider. AWS trusts that issuer via an IAM OIDC identity provider. A workflow assumes an IAM role using sts:AssumeRoleWithWebIdentity and receives temporary credentials scoped to what the role allows.

Setup steps

Example trust condition

sub: repo:org/repo:ref:refs/heads/main

Tighten conditions so only expected workflows and branches can assume the role. Avoid wildcard * on production roles.

Outcomes