TL;DR
- GitHub Actions can request a short-lived OpenID Connect (OIDC) token that a cloud identity provider exchanges for temporary credentials. This removes long-lived cloud access keys from CI secrets.
- The workflow permission
id-token: writeallows token retrieval. It does not grant cloud access by itself. Cloud trust policies and IAM roles define what the job can do. - Restrict trust to the intended repository, branch or protected environment, audience, and workflow where supported. Keep deployment permissions narrow and pin third-party actions to reviewed commit SHAs.
- AWS, Google Cloud, and Microsoft Entra ID use different trust configuration models. Configure each separately and verify the exact token subject claims your repository emits.
- Protect the deployment branch, workflow files, environments, and approvals. A compromised trusted workflow can still exercise every cloud permission its role grants.
Why keyless CI still needs a trust boundary
A static cloud access key stored in a repository or organization secret can remain usable until someone rotates or revokes it. It may be copied into logs, artifacts, a compromised action, or an unintended job. OpenID Connect federation removes that long-lived credential from the GitHub secret store. The cloud provider trusts a signed identity token from GitHub, validates its claims, and issues credentials with a limited lifetime.
“Keyless” does not mean “credential-free” or “automatically safe.” The workflow still obtains a token. The cloud identity provider still needs a trust policy. The role still needs resource permissions. If a pull request from an untrusted fork can run a privileged deployment job, or if a trust policy accepts every repository in an organization, federation has only changed how the credential is minted.
Model the chain as three separate decisions:
- GitHub decides which workflow job can request an OIDC token. The job needs
id-token: write. - The cloud provider validates issuer, audience, subject, and mapped attributes against its federation policy.
- The resulting cloud principal is authorized by a narrowly scoped role or resource policy.
The token permission enables the first step. It is not permission to modify cloud resources. GitHub’s OIDC reference documents the issuer, audience, subject, and additional claims available to providers. GitHub Actions OIDC token reference
Use claims to restrict who can deploy
A GitHub OIDC token includes an issuer (iss), an audience (aud), and a subject (sub). Other claims describe the repository, owner, ref, environment, workflow, and run. The subject format depends on workflow context and repository configuration. Branch, tag, pull request, and GitHub environment jobs can produce different subjects.
As of 2026, GitHub has introduced immutable owner and repository IDs in subject formats for repositories created, renamed, or transferred after the rollout date, while older repositories may still use name-based subjects unless they opt in. Cloud trust conditions written against an old name-only subject can stop matching after a repository changes its subject format. A mutable name can also be reused. Review GitHub’s current claim format and the cloud provider’s condition syntax before setting policy. GitHub OIDC claims and subject formats
Prefer an exact trust relationship for the deployment workflow and branch or environment. Avoid wildcards that trust every branch, pull request, or repository. For production, use a protected GitHub environment with required reviewers and deployment branch restrictions, and bind cloud trust to that environment subject. A branch condition alone may be insufficient if workflow files can be modified by anyone who can merge to the branch.
Reusable workflows add another identity boundary. When a shared workflow performs deployment, constrain the cloud role to the approved repository and reusable workflow reference where the provider supports those claims. Review the trust policy when you change the workflow, environment name, repository name, or identity format.
Set up an AWS role for GitHub Actions
AWS registers GitHub’s OIDC issuer as an IAM identity provider. An IAM role trust policy then permits sts:AssumeRoleWithWebIdentity only when audience and subject match. The role’s permissions policy separately grants actions against selected resources. AWS documents using token.actions.githubusercontent.com:sub to limit which GitHub identities can assume a role. Current guidance also describes immutable subject claims and identity-provider controls, so use current conditions instead of copying an old example unchanged. GitHub’s AWS federation guide · AWS OIDC identity-provider controls
Conceptually, the trust policy requires the GitHub OIDC provider, the expected AWS audience, and an exact allowed subject. Use the subject format emitted by your repository, including immutable IDs if applicable. Do not loosen the condition to a wildcard to work around a mismatch. Inspect a non-production token’s claims and align the policy with the intended protected branch or environment.
The following workflow is illustrative. Replace the role ARN and region, pin actions to reviewed full commit SHAs in production, and keep the role limited to the deployment target.
name: Deploy production
on:
push:
branches: [main]
permissions:
contents: read
jobs:
deploy:
environment: production
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::123456789012:role/site-deploy
aws-region: us-east-1
- run: aws sts get-caller-identity
- run: ./scripts/deploy-production.sh
The action tag above is illustrative, not a supply-chain recommendation. Pin actions to a reviewed full commit SHA and update them through a controlled process. The AWS credentials action exchanges the GitHub identity token for a role session; the role policy determines what that session can change. AWS configure credentials action
Configure Google Cloud Workload Identity Federation
Google Cloud Workload Identity Federation uses a pool and OIDC provider to accept external identities without service-account key files. Map trusted claims to attributes, then define a condition that limits which GitHub organization, repository, branch, or environment can exchange a credential. Google recommends attribute conditions when using GitHub because it is a multi-tenant identity provider with a shared issuer across organizations.
Google documents conditions using claims such as assertion.repository_owner and assertion.ref. A deployment-specific condition should include the exact organization and repository, plus the protected ref or environment. Grant the resulting principal only roles needed to deploy the target resource. Use direct federation where supported; if you impersonate a service account, grant the minimum identity role on that account and keep its resource roles narrow. Google Cloud federation for deployment pipelines · Google Cloud federation security practices
The workflow grants id-token: write and invokes Google’s authentication action with a workload identity provider. The provider’s audience, attribute mapping, condition, and IAM bindings must already exist.
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: google-github-actions/auth@v3
with:
project_id: example-project
workload_identity_provider: projects/123456789/locations/global/workloadIdentityPools/github/providers/actions
- run: gcloud auth list
- run: ./scripts/deploy-google-cloud.sh
Google’s authentication action documents that checkout should run before authentication where generated credentials or repository context are needed, and that GitHub tokens and derived credentials have limited lifetimes. Keep authentication close to deployment and do not save generated credentials into artifacts or caches. Verify the behavior of the action version and cloud APIs you use.
Federate with Microsoft Entra ID for Azure
Microsoft Entra ID creates a federated identity credential on an application or supported managed identity. The credential matches the GitHub token issuer, audience, and subject. Azure login exchanges the token, then Azure role-based access control determines which resources the job can modify.
Configure the credential for the exact organization, repository, and branch, tag, or GitHub environment that deploys. Subject matching is exact for standard credential types, so the workflow context must match what was registered. Microsoft’s current guidance also describes immutable GitHub subject formats and migration considerations. A repository rename or transfer can affect name-based subjects, so follow the documented migration steps. Microsoft Entra OIDC authentication for GitHub Actions · GitHub immutable subject migration guidance
The workflow needs client, tenant, and subscription identifiers used by the Azure login action. These identify the target identity and subscription; the federated credential and Azure role assignment enforce access. A federated login should not need a long-lived client secret.
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v4
- uses: azure/login@v3
with:
client-id: AZURE_CLIENT_ID
tenant-id: AZURE_TENANT_ID
subscription-id: AZURE_SUBSCRIPTION_ID
- run: az account show
- run: ./scripts/deploy-azure.sh
Whether these IDs live in GitHub secrets or repository variables is a configuration choice. They are not equivalent to a secret credential. Keep production identity details scoped to a protected environment if that helps review and access control.
Protect the workflow that receives the token
OIDC moves trust from a stored password to a signed identity, but a malicious workflow can request a valid token if it runs in a trusted context. Require review for changes to deployment workflows, reusable workflows, environment rules, action versions, and infrastructure code. Protect production with required reviewers and restrict which branches can deploy.
Set permissions at the job that needs them. Explicitly grant only the needed GitHub token permissions such as contents: read and id-token: write. Untrusted pull requests should not receive production deployment credentials. Keep checkout, build, and deploy steps arranged so untrusted artifacts cannot alter a privileged deployment action after approval.
Pin third-party actions to full commit SHAs and review updates. Do not print raw OIDC tokens or temporary credentials. Cloud audit logs should identify the assumed role and session, while deployment records should identify the repository, commit, workflow, and environment. Use distinct roles for staging and production so an environment mistake cannot inherit production permissions.
Keep deployment permissions narrow. A static site deploy may need write access to one bucket and cache invalidation for one distribution. It should not receive account administrator rights. Consider separating unprivileged build work from the short privileged upload job.
Test trust conditions before switching production
Start in a non-production cloud account or resource. Create a minimal role with read-only identity inspection or permission to write a disposable resource. Run the intended workflow and verify that its token is accepted. Then test that a feature branch, forked pull request, wrong repository, and wrong environment are rejected.
Check both authentication and authorization. Successful aws sts get-caller-identity, gcloud auth list, or az account show proves identity exchange completed. It does not prove that the role has only the permissions it should. Review policy simulation or access analysis where available, and attempt a forbidden action in a disposable environment.
Record the issuer, audience, subject, repository claims, and environment used by the trusted workflow. Do not leave token dumps in public logs. If a repository rename, transfer, environment rename, action change, or organization policy changes, rerun trust tests. Check cloud audit logs after the first production run.
Failure messages often indicate a mismatch between the emitted subject and configured trust. Do not broaden the trust condition until the workflow works. First inspect the claim format and understand which boundary is mismatched. Broad wildcards can silently permit more workflows than intended.
OIDC handles cloud identity, while action and dependency provenance remain separate concerns. See our guide to Python supply-chain controls for locked dependencies, hashes, and software bills of materials, and our SOC 2 engineering guide for evidence collection around protected changes.
Frequently asked questions
Does id-token: write give a GitHub workflow permission to deploy to cloud resources?
No. It lets the job request a GitHub OIDC token. The cloud provider must trust the token’s issuer, audience, and subject, and the resulting role must have permissions for the target resource. Keep the token permission limited to the deployment job and configure the cloud role with least privilege.
Should I put AWS, Azure, or GCP client identifiers in GitHub secrets?
Client IDs, tenant IDs, subscription IDs, project IDs, and role identifiers are generally configuration identifiers, not secret credentials. Organizations may still put them in environment secrets for access scoping or consistency. The security boundary is the federated trust policy and cloud role, not secrecy of the identifier.
What happens if I rename the GitHub repository after configuring OIDC?
Name-based subject conditions may stop matching after a rename or transfer, and name reuse can create trust risks. GitHub supports immutable owner and repository IDs in subject formats for eligible repositories. Review the token’s actual subject and cloud provider’s current migration instructions before changing trust.
Can one OIDC role deploy to both staging and production?
Separate roles usually make the boundary easier to audit. Bind each role to its own protected branch or environment and give it access only to that environment’s resources. A single role can have strict conditions, but mistakes can expose production permissions to staging workflows.
Replace stored keys with explicit federated trust
GitHub Actions OIDC can remove long-lived cloud keys from CI while making workflow identity and trust policy explicit. Configure token audience and subject narrowly, assign a least-privilege role, protect the workflow and environment, and test that unintended jobs are denied. Revisit subject formats when repositories or workflows change. If you are hardening deployments across AWS, Azure, or Google Cloud, talk to our engineering team about federation boundaries, role design, and deployment verification.
