Interview Prep/DevSecOps/Identity, Least Privilege & OIDC for CI

How do you design AWS OIDC trust for GitHub Actions so only production deploys can assume the prod role?

IntermediateProductionIdentity, Least Privilege & OIDC for CI
Answer

Restrict the sub claim to an environment, which also lets you put required reviewers on that environment.

{
  "Effect": "Allow",
  "Principal": { "Federated": "arn:aws:iam::111122223333:oidc-provider/token.actions.githubusercontent.com" },
  "Action": "sts:AssumeRoleWithWebIdentity",
  "Condition": {
    "StringEquals": {
      "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
      "token.actions.githubusercontent.com:sub": "repo:acme/payments-api:environment:production"
    }
  }
}

Never use StringLike with repo:acme/* for a prod role; any repo in the org (or a fork workflow) could then assume it.

All DevSecOps questions Roadmap: Supply chain, secrets & identity

More on Identity, Least Privilege & OIDC for CI