Interview Prep/CI/CD/GitHub Actions and GitLab CI in Production

How do you design the GitHub Actions OIDC trust policy for AWS safely?

AdvancedProductionGitHub Actions and GitLab CI in Production
Answer

Create the IAM OIDC provider for token.actions.githubusercontent.com, then a role per purpose (plan, deploy-staging, deploy-prod) with a trust policy that pins the audience and a specific sub. For production, bind to a GitHub environment so only approved jobs can assume it.

{
  "Effect": "Allow",
  "Principal": { "Federated": "arn:aws:iam::123456789012: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/shop-api:environment:production"
    }
  }
}

Never use wildcards like repo:acme/* for production roles, and give each role least-privilege permissions.

All CI/CD questions Roadmap: GitLab CI/CD

More on GitHub Actions and GitLab CI in Production