All guides

Keyless deploys to AWS and Google Cloud with OIDC

The pattern is the same for both clouds. The workflow receives a token from GitHub's OIDC provider, and an action exchanges it for a short-lived cloud credential. No long-lived cloud credential is stored in GitHub.

Hands typing on a laptop

AWS: a role that trusts one repository

Add GitHub as an OIDC identity provider in IAM, with the provider URL https://token.actions.githubusercontent.com and the audience sts.amazonaws.com. Then give the role a trust policy. This is the example from the AWS IAM documentation, with the account, organization, repository and branch for you to change:

JSON

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": {
      "Federated": "arn:aws:iam::111122223333: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:my-org/my-repo:ref:refs/heads/main"
      }
    }
  }]
}

The workflow is the example from the README of aws-actions/configure-aws-credentials:

YAML

# Need ID token write permission to use OIDC
permissions:
  id-token: write
jobs:
  run_job_with_aws:
    runs-on: ubuntu-latest
    steps:
      - name: Configure AWS Credentials
        uses: aws-actions/[email protected]
        with:
          role-to-assume: <Role ARN you created in step 2>
          aws-region: <AWS Region you want to use>
      - name: Additional steps
        run: |
          # Your commands that require AWS credentials
          aws sts get-caller-identity

The assumed role session lasts 1 hour by default. The action's role-duration-seconds input accepts 900 to 43200 seconds.

Google Cloud: Workload Identity Federation

Create a workload identity pool and an OIDC provider with the issuer https://token.actions.githubusercontent.com. The README of google-github-actions/auth says to always add an attribute condition that restricts entry into the pool, and shows assertion.repository_owner == '${GITHUB_ORG}' as a good default. A claim has to be mapped to an attribute before a condition can use it.

The README calls direct Workload Identity Federation the preferred setup, because the pool has IAM permissions on the resources directly, with no intermediate service account or key. It names two limits: some Google Cloud resources do not support principalSet identities, and the token it yields lives for 10 minutes at most. This is its usage example:

YAML

jobs:
  job_id:
    # Any runner supporting Node 20 or newer
    runs-on: ubuntu-latest

    # Add "id-token" with the intended permissions.
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - uses: 'actions/checkout@v7'

    - uses: 'google-github-actions/auth@v3'
      with:
        project_id: 'my-project'
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'

Three rules for both

  1. Condition on the subject. GitHub says at least one condition is mandatory. It keeps untrusted repositories from requesting access tokens. AWS warns that with no limit on the sub key, GitHub Actions from organizations or repositories outside your control can assume the role.
  2. Environments. For a job that uses an environment, the subject is repo:ORG-NAME/REPO-NAME:environment:ENVIRONMENT-NAME. GitHub recommends protection rules on that environment, such as restricting which branches can deploy to it.
  3. Remove the old keys. OIDC removes the need to store cloud credentials as long-lived GitHub secrets. Delete those secrets once the workflow uses OIDC.

Check new repositories

Repositories created after 15 July 2026 use an immutable subject format with the owner ID and the repository ID, as in repo:octo-org@123456/octo-repo@456789:ref:refs/heads/main. Renames and transfers after that date move a repository to the same format, and older repositories keep the previous format unless they opt in. GitHub's reference says "after" that date; the AWS action README says "on or after".

A trust policy in the name-only form does not match the immutable claim. On AWS the call then fails with Not authorized to perform sts:AssumeRoleWithWebIdentity. Update the sub condition to the form your repository emits.

For Azure, see [Set up OIDC between GitHub Actions and Azure](github-azure-oidc.html).

Sources

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides