Interview Prep/GitHub Actions/OIDC & Security Hardening

What are the `sub` claim formats, and which do you put in an AWS trust policy?

AdvancedConceptOIDC & Security Hardening
Answer
  • Branch push: repo:ORG/REPO:ref:refs/heads/main
  • Tag: repo:ORG/REPO:ref:refs/tags/v1.4.0
  • Environment job: repo:ORG/REPO:environment:prod (replaces the ref form)
  • Pull request: repo:ORG/REPO:pull_request
"Condition": {
  "StringEquals": {
    "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
    "token.actions.githubusercontent.com:sub": "repo:devopsshack/shack-api:environment:prod"
  }
}

Use StringLike only for deliberate wildcards like repo:devopsshack/shack-api:ref:refs/tags/v*. Never repo:devopsshack/* for a prod role. Orgs can customize the sub template (for example, to include job_workflow_ref) via the OIDC customization API.

All GitHub Actions questions Roadmap: GitHub Actions

More on OIDC & Security Hardening