Interview Prep/Git & GitHub/Security: secrets, signing, access and supply chain

Why use OIDC federation for cloud credentials from GitHub Actions instead of stored keys?

IntermediateProductionSecurity: secrets, signing, access and supply chain
Answer

The workflow gets a short-lived OIDC token per run, and the cloud (AWS, Azure, GCP) trusts it only for specific repos, branches or environments through the sub claim. No long-lived key sits in secrets to leak or rotate. Scope the trust policy tightly, for example to repo:org/app:environment:production.

permissions:
  id-token: write
  contents: read
steps:
  - uses: aws-actions/configure-aws-credentials@v4
    with:
      role-to-assume: arn:aws:iam::123456789012:role/gha-deploy
      aws-region: ap-south-1
All Git & GitHub questions Roadmap: Git & GitHub

More on Security: secrets, signing, access and supply chain