AI Hints
CI/CD with GitHub Actions · Lesson 93 of 138

Cloud Login with OIDC

No stored keys.

⏱ 2 min read▶ Video at 1:47:14🎓 Free
Watch this lesson in the CI/CD with GitHub Actions courseWatch on YouTube ↗Full CI/CD with GitHub Actions course

To deploy to a cloud, the workflow needs permission. The old way was storing a cloud key as a secret. Keys like that never expire, and if they leak, it's a disaster. OIDC is the modern way, with no stored keys at all.

Cloud Login with OIDC
From the video: Cloud Login with OIDC
  • Cloud keys in secrets
  • They never expire
  • OIDC: no stored keys

How OIDC works

The job asks GitHub for a signed token, that says which repository, branch, and workflow it is. It hands the token to the cloud. The cloud checks the signature, and its trust rules, like only main of sam slash shop. Then it gives back short lived credentials, that expire in about an hour.

  1. Job asks GitHub
  2. Signed token
  3. Cloud checks rules
  4. Short-lived keys
How OIDC works
From the video: How OIDC works

OIDC with AWS

ID token write lets the job request the token. The configure AWS credentials action swaps it for credentials, by assuming a role. The role's trust policy, set up once in AWS, decides which repositories and branches are allowed. Then the AWS tools just work.

.github/workflows/deploy.ymlyaml
permissions:
  id-token: write
  contents: read
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: aws-actions/configure-aws-credentials@v4
        with:
          role-to-assume: arn:aws:iam::123456789012:role/deploy
          aws-region: eu-west-1
      - run: aws s3 ls

Summary

OIDC swaps a signed GitHub token for short lived cloud credentials. No keys to store, rotate, or leak. Azure and Google Cloud support it too. Next, checking a deployment really worked.

Key takeaways
  • id-token: write
  • Trust rules in the cloud
  • Short-lived keys
Next up: Smoke Tests — is it really up?