Skip to main content
Back to Blog
DevOps

GitHub Actions OIDC for AWS: Retire Your Stored Access Keys

Replace long-lived AWS keys in GitHub Actions with OIDC roles: trust policies that hold up, the July 2026 subject claim change, and a safe cutover.

PlatOps Team
Author
Published: November 5, 2026
8 min read

Most small teams wire GitHub Actions to AWS the same way: someone creates an IAM user called github-deploy, attaches AdministratorAccess "for now", and pastes the access key into a repository secret. Three years later the key has never been rotated, it lives in four repositories, and the person who created it has left.

That key is a password that never expires, and anything that can read your workflow's secrets can copy it. In March 2025 that happened at scale: the tags of the popular tj-actions/changed-files action were moved to a malicious commit, and CVE-2025-30066 records that attackers could "discover secrets by reading actions logs". A static key leaked that way keeps working until someone notices.

GitHub Actions can authenticate to AWS with OpenID Connect (OIDC) instead, so there is no stored key to leak. Most of the setup is a few minutes of work. The part that goes wrong is the IAM trust policy, and since July 15, 2026 GitHub has been changing the identity format that policy matches on. Here is how to set it up so it holds, and how to cut over without breaking deploys.

TL;DR

  1. With OIDC, each workflow job gets a signed token from GitHub and exchanges it for AWS credentials that expire after one hour by default; nothing long-lived sits in your secrets.
  2. The IAM role's trust policy is the security boundary. It must check the token's sub claim against a specific repository, and ideally a specific branch or environment.
  3. IAM rejects trust policies for GitHub's provider that omit sub or set it to only a wildcard, but repo:your-org/* still passes and still lets every repository in the organization assume the role.
  4. Repositories created, renamed or transferred after July 15, 2026 receive a new sub format with numeric owner and repository IDs, such as repo:acme@123456/app@456789:ref:refs/heads/main. Name-based trust policies will not match them.
  5. Cut over one repository at a time, watch CloudTrail for the old key going quiet, then deactivate the key before you delete it.

How the exchange works

When a job declares id-token: write, GitHub's OIDC provider at https://token.actions.githubusercontent.com issues a JSON Web Token (JWT) describing that job: which repository, which branch or environment, which workflow. The job sends it to AWS STS (AssumeRoleWithWebIdentity). STS checks the signature, evaluates the role's trust policy against the token's claims, and returns temporary credentials. The official aws-actions/configure-aws-credentials action does all of this and exports the credentials to later steps; its default session length is one hour, configurable from 15 minutes to 12 hours.

You no longer need to look up a certificate thumbprint for GitHub's provider. AWS verifies the provider's TLS certificate against its own trusted root CAs and only falls back to the thumbprint when it cannot.

Setup is one identity provider per AWS account, then one role per repository and environment:

aws iam create-open-id-connect-provider \
  --url https://token.actions.githubusercontent.com \
  --client-id-list sts.amazonaws.com

The workflow side is short:

permissions:
  id-token: write   # lets the job request the OIDC token
  contents: read

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - uses: actions/checkout@<full-commit-sha>  # v4
      - uses: aws-actions/configure-aws-credentials@<full-commit-sha>  # v6.3.0
        with:
          role-to-assume: arn:aws:iam::111122223333:role/gha-app-production
          aws-region: us-east-1
      - run: aws sts get-caller-identity

Pin third-party actions to a full commit SHA with the version in a comment; our supply chain playbook explains why a moving tag is the weak point.

The trust policy is the security boundary

The token proves only that some GitHub Actions job produced it. GitHub's OIDC reference says you "must define at least one condition, so that untrusted repositories can't request access tokens for your cloud resources". Without a sub check, any repository on github.com that knows your role ARN can assume the role.

AWS now enforces a floor. Per the IAM documentation, when GitHub's provider is the principal, IAM checks that token.actions.githubusercontent.com:sub is present and "is not solely a wildcard character (* and ?) or null", and rejects the create or update if it is. That stops the worst mistake. It does not stop a broad one.

A production role should match one repository and one environment:

{
  "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:acme/app:environment:production"
      }
    }
  }]
}

Matching the environment only means something if the environment is protected. Under Settings → Environments → production, add required reviewers and restrict deployment branches to main. Otherwise any branch can declare environment: production and receive the role. AWS's documentation makes the same recommendation.

The common sub patterns, and what each one lets in:

sub conditionWhat it allowsVerdict
none, or *Any repository on github.comRejected by IAM on create or update; older policies may still exist
repo:acme/*Every repository, branch and pull request in your organizationToo broad for anything that can deploy
repo:acme/app:*Every branch and pull request in one repositoryAcceptable for a read-only role, such as terraform plan
repo:acme/app:ref:refs/heads/mainPushes to main in one repositoryGood
repo:acme/app:environment:productionJobs using the protected production environmentBest for deploy roles

Two details catch people out. First, when a job references an environment, the sub claim takes the environment form, so a policy matching ref:refs/heads/main stops matching the moment you add environment: to the job. Second, the IAM console's GitHub wizard fills an empty repository field with *. If you leave it blank, the role trusts the whole organization.

The July 2026 subject claim change

On April 23, 2026 GitHub announced immutable subject claims. The problem it fixes: names on GitHub can be recycled. If you delete or rename an organization or repository, someone else can register the old name, and a trust policy written against repo:acme/app would then match their tokens. It is the same class of risk as a dangling DNS record, which we covered in subdomain takeover.

The new default sub adds numeric IDs that never get reused, separated from names by @:

old: repo:acme/app:ref:refs/heads/main
new: repo:acme@123456/app@456789:ref:refs/heads/main

What changed on July 15, 2026, per the changelog:

  • Repositories created after that date get the new format automatically.
  • Repositories renamed or transferred after that date switch to the new format.
  • Existing repositories keep the old format unless you opt in, at the repository or organization level, under the OIDC settings or through the API.
  • It applies to github.com only, not GitHub Enterprise Server.

The failure mode is quiet. Nothing breaks on July 15. It breaks the day someone creates a new service repository and copies the deploy workflow from an old one, or renames app to api. The job then fails with Not authorized to perform sts:AssumeRoleWithWebIdentity, because the trust policy still expects the old string.

Look up the IDs with the GitHub CLI:

gh api repos/acme/app --jq '"owner=\(.owner.id) repo=\(.id)"'

During a transition you can accept both forms, since multiple values for one condition key are OR'd:

"StringEquals": {
  "token.actions.githubusercontent.com:aud": "sts.amazonaws.com",
  "token.actions.githubusercontent.com:sub": [
    "repo:acme/app:environment:production",
    "repo:acme@123456/app@456789:environment:production"
  ]
}

Once the repository has opted in and deploys pass, remove the name-based line. Only the ID-based form protects you against a recycled name.

Cutting over without breaking deploys

The order matters more than the YAML.

  1. Inventory the keys. List IAM users with access keys and when each was last used. aws iam generate-credential-report followed by aws iam get-credential-report gives you a CSV with access_key_1_last_used_date and access_key_1_last_used_service for every user. Then search your organization's repository secrets for AWS_ACCESS_KEY_ID.
  2. Build the role in code. Define the provider and one role per repository and environment in Terraform or CloudFormation, with the narrowest sub you can and only the permissions that deploy needs. Clicking roles together in the console is how repo:acme/* ends up in production.
  3. Switch one repository. Change the workflow to role-to-assume, and add id-token: write. Leave the old secret in place for now. Run a deploy.
  4. Confirm in CloudTrail. Successful runs appear as AssumeRoleWithWebIdentity events for the new role. The old key's last_used_date should stop advancing.
  5. Deactivate before you delete. aws iam update-access-key --access-key-id AKIA... --status Inactive --user-name github-deploy. Wait a week of normal releases. If nothing fails, delete the key, delete the repository secret, then delete the IAM user.
  6. Repeat per repository, and add a check to new-repository setup: the deploy role is created from the repository's IDs, never by copying a sibling's policy.

The step teams skip is the last one in step 5. A deactivated key and a forgotten IAM user are exactly what turns up later in an audit, or in a breach report.

Who owns this

None of this is difficult, but it falls between roles: developers own the workflows, whoever set up AWS owns IAM, and nobody owns the moment a repository gets renamed. If you want it done once and kept current, our CI/CD pipeline service sets up OIDC roles per repository and environment in Terraform, removes the stored keys and revokes them. If you want the rest of the account checked at the same time, our Cloud + DevOps Audit Sprint includes an IAM over-permission review alongside cost and single points of failure, in 30 days for a fixed $5,000. For the wider identity picture, see our zero trust guide for small businesses.

Frequently asked questions

Does the July 2026 change break existing GitHub Actions deployments to AWS? No. Repositories that existed before July 15, 2026 keep the old name-based sub format unless you opt in. Deployments break when a repository is created, renamed or transferred after that date and its role's trust policy still matches the old format. Check those repositories first, and add the ID-based value to their trust policies.

Can I use one IAM role for all repositories in our GitHub organization? IAM will accept repo:your-org/*, but every repository and every branch in the organization can then assume the role, including a test repository someone created last week. Use one role per repository and environment, and keep broad patterns for read-only roles at most.

Does this also apply to Azure and Google Cloud? The same tokens are used, so the new sub format reaches every cloud. On Azure, a federated identity credential on a Microsoft Entra application must match the subject exactly and does not support wildcards, so a new or renamed repository needs a new credential. On Google Cloud, check your workload identity provider's attribute condition, which usually matches on repository names.

Put this into practice

Book a free 30-minute call with a senior engineer about your infrastructure, or check your email security in 30 seconds.

Tags:github-actionsawsoidcci-cddevopssecurity

Get articles like this in your inbox

Practical security, infrastructure, and DevOps insights for teams in regulated industries. Sent every two weeks.

Every two weeksUnsubscribe anytimeNo spam, ever

Security and cloud notes from PlatOps Security, LLC, every two weeks. We use your address only to send them. We will email you a link to confirm, and every issue has a one-click unsubscribe. Privacy Policy.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Free 30-minute call

Want to Talk This Through?

Book a free 30-minute call, and we'll go through how this applies to your business and what to do first.

No commitment. Video call or phone, whichever you prefer. Run by senior engineers, serving clients since 2014.

What you leave the call with

  • How this applies to your setup
  • What to do first
  • A senior engineer, not a salesperson
Book a free 30-minute call

Prefer it in writing? Request a written review