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
More on Security: secrets, signing, access and supply chain
What are the first things you do when a secret is committed to a repo?BeginnerHow do you prevent secrets from entering the repo in the first place?IntermediateWalk through purging a leaked secret from a 5 GB repo with 200 contributors.AdvancedWhat is your policy on signed commits and how do you enforce it?IntermediateWhat do signed commits not protect against, and what supply chain controls complement them?AdvancedWhy pin third-party GitHub Actions to a commit SHA?Intermediate