Keel

How do you connect GitHub Actions to AWS without access keys?

By the Keel team · Last checked · 4 min read

Short answer

Connect GitHub Actions to AWS with OpenID Connect. You add GitHub as an identity provider in IAM and create a role whose trust policy accepts it, and the workflow requests short-lived credentials for each run. No AWS access keys are stored in GitHub, so there is no long-lived secret to leak or rotate.

How do you connect GitHub Actions to AWS without access keys?

Create an IAM OIDC identity provider for GitHub, an IAM role that trusts it, and let the workflow assume that role.

AWS's IAM guidance says to rely on temporary credentials rather than long-term access keys where possible, and for workloads outside AWS it lists AssumeRoleWithWebIdentity as one way to get them.

  1. The workflow asks GitHub's OIDC provider for a signed token.
  2. AWS checks the token against the trust policy on your role.
  3. If the conditions match, AWS returns temporary credentials.
  4. The job uses them and they expire.

What do you set up in AWS?

Add an OIDC identity provider with the URL https://token.actions.githubusercontent.com and the audience sts.amazonaws.com, then create the role.

GitHub's guidance requires at least one condition in the trust policy, so untrusted repositories cannot request tokens.

This trust policy lets one repository assume the role only from a protected production environment. Replace the placeholders with your account ID, organisation and repository.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "Federated": "arn:aws:iam::ACCOUNT-ID: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:YOUR-ORG/YOUR-REPO:environment:production"
        }
      }
    }
  ]
}

Then attach a permissions policy with only what the deploy needs.

Nothing in this policy is a secret. It names who may assume the role, so it can live in your infrastructure code and be reviewed like any other change. That is the practical gain over stored keys: there is no credential to rotate, only a rule to review, and the temporary credentials the job receives expire on their own.

What does the workflow look like?

The job needs permissions: id-token: write so GitHub can create the token, and the aws-actions/configure-aws-credentials action takes the role ARN.

GitHub notes this setting only lets the workflow request and use an OIDC token; it does not grant write access to resources.

name: deploy
on:
  push:
    branches: [main]

permissions:
  id-token: write   # request the OIDC token
  contents: read    # check out the code

jobs:
  deploy:
    runs-on: ubuntu-latest
    environment: production
    steps:
      - uses: actions/checkout@v6
      - uses: aws-actions/configure-aws-credentials@v6.2.4
        with:
          role-to-assume: arn:aws:iam::ACCOUNT-ID:role/github-deploy-production
          aws-region: eu-west-2
      - run: aws sts get-caller-identity

The action's own README pins a specific release in its examples. Pinning is the more conservative choice, and checking its releases page before you choose a tag is sensible. For what the deploy step itself should do, see CI/CD for Amazon ECS in a small team.

How should you scope the sub claim?

Match the exact repository and either a branch or an environment, never a broad wildcard.

GitHub recommends evaluating token.actions.githubusercontent.com:sub in every trust policy that trusts its provider. The standard forms are repo:ORG/REPO:ref:refs/heads/BRANCH and repo:ORG/REPO:environment:ENVIRONMENT.

GitHub's own wildcard example, repo:ORG/REPO:*, allows any branch, pull request merge branch or environment in that repository. That is fine for a staging role and wrong for production. AWS's guidance for this action also warns against ForAllValues: in Allow statements, because it can return true when a claim is missing or misspelled.

How should permissions be split between environments?

Use one role per environment, each with the least it needs.

A staging role can be reachable from pull request workflows. A production role should be reachable only from a protected environment that needs approval. A read-only role suits jobs that only check things.

RoleTrusted fromCan do
github-deploy-stagingBranch or environment for stagingDeploy to staging only
github-deploy-productionThe production environment, one repositoryDeploy to production only
github-readonlyPull requestsRead-only checks such as plans

Do not give a deploy role administrator permissions. If your pipeline also rolls back, see rolling back an ECS deployment automatically.

How do you check it works, and what are the common mistakes?

Run the workflow and confirm aws sts get-caller-identity shows the role you expect.

Look in CloudTrail for the role assumption. Then run the workflow from a branch or repository that should be refused and confirm it fails, because a trust policy that accepts everything also passes the first test.

  • A trust policy that allows any repository in the organisation to assume a production role.
  • A role with more permissions than the deploy needs.
  • Leaving the old access keys in GitHub secrets and IAM, where they keep working until deleted.
  • Forgetting id-token: write, so the job never gets a token.

Delete the old keys last. For secrets that cannot be avoided, see keeping database passwords and API keys on AWS, and for the human side of access, IAM Identity Center or IAM users.

Is your pipeline free of stored keys?

Tick each item that is true today.

  • No AWS access keys are stored in GitHub secrets.
  • Each workflow has permissions: id-token: write only where needed.
  • Each trust policy names an exact repository and branch or environment.
  • Production has its own role behind a protected environment.
  • Deploy roles have only the permissions a deploy needs.
  • A run from a wrong branch has been tested and refused.

Decision point: Five or six ticks: your pipeline is sound. Three or fewer: a leaked key or a loose trust policy is the likeliest risk.

Sources

  1. GitHub docs, Configuring OpenID Connect in Amazon Web Services (checked November 2026)
  2. GitHub, aws-actions/configure-aws-credentials (checked November 2026)
  3. AWS docs, Security best practices in IAM (checked November 2026)

Keep reading

Keel is an AWS release and recovery operations service for SaaS teams of 3 to 15 developers, provided by Bargainn Services Ltd, a UK company registered at Companies House (16497746). Registered office: 3rd Floor, 86-90 Paul Street, London, EC2A 4NE, United Kingdom.