Workload identity federation: setup for AWS, Google Cloud, Azure and Kubernetes
Workload identity federation replaces stored cloud keys with a token exchange: a workload presents a short-lived, signed OIDC token from the platform it runs on (a GitHub Actions job, a Kubernetes pod, a VM in another cloud), the target cloud validates the token's issuer, audience and subject against a trust policy you wrote, and returns credentials that expire in minutes to hours. AWS does this with an IAM OIDC provider and AssumeRoleWithWebIdentity, Google Cloud with workload identity pools and its Security Token Service, and Microsoft Entra with federated identity credentials. The security of the whole arrangement comes down to how tightly you write the subject condition.
This guide is the hands-on companion to Workload identity 101, which covers why static secrets fail and where SPIFFE fits. Here we set up federation for the four places teams usually start, then cover the misconfigurations that turn federation into an open door. Every config name below is taken from the vendor documentation linked in each section (checked 1 December 2026).
How the exchange works
- The platform issues a token. GitHub mints a JWT for each job that asks for one; Kubernetes projects a service account token into the pod. Both are signed by an issuer that publishes an OIDC discovery document and a JWKS.
- The workload sends it to the cloud's token service. AWS STS, Google Cloud STS (which follows OAuth 2.0 token exchange, RFC 8693) or the Microsoft identity platform.
- The cloud validates the token. Signature against the issuer's published keys, then claims against your trust configuration:
iss: is this an issuer I registered?aud: was this token minted for me, not for some other relying party?sub(and, where supported, other claims): is this the specific repository, branch, environment, namespace or service account I meant to trust?
- The cloud returns short-lived credentials scoped to one role, service account or managed identity.
Two facts drive every misconfiguration later in this guide. First, GitHub uses a single issuer, https://token.actions.githubusercontent.com, for every repository on github.com, so checking the issuer alone trusts every GitHub user on the planet. Second, the aud check is what stops a token minted for one service from being replayed to another.
The GitHub Actions token
From GitHub's OIDC reference, the default sub claim depends on what triggered the job:
| Job context | sub format |
|---|---|
| Job uses an environment | repo:ORG/REPO:environment:NAME |
pull_request event (no environment) |
repo:ORG/REPO:pull_request |
| Branch (no environment, not a PR) | repo:ORG/REPO:ref:refs/heads/BRANCH |
| Tag (no environment, not a PR) | repo:ORG/REPO:ref:refs/tags/TAG |
Two details catch people out:
- Immutable subjects. Repositories created after 15 July 2026 use an immutable format by default,
repo:OWNER@OWNER-ID/REPO@REPO-ID:ref:refs/heads/BRANCH, for examplerepo:octo-org@123456/octo-repo@456789:ref:refs/heads/main. Older repositories keep the name-based format unless they opt in, and renames or transfers after that date move to the new format. Not available on GitHub Enterprise Server. If your trust policy pins the old format, a repository rename will break deploys (which is the point: a renamed or re-created repository is no longer the one you trusted). - Default audience. GitHub sets
audto the URL of the repository owner unless the action requests a custom audience. The official cloud actions requeststs.amazonaws.com(AWS) andapi://AzureADTokenExchange(Azure).
Every workflow that federates needs permissions: id-token: write, which, per GitHub, "only allows the workflow to request (fetch) and use (set) an OIDC token." Org and repository admins can also customize the subject template with include_claim_keys, for example to put job_workflow_ref (a specific reusable workflow) or the numeric repository_id into sub. Create the matching cloud condition before applying a customization, or tokens will be rejected.
GitHub Actions to AWS
1. Register the provider. In IAM, add an OpenID Connect identity provider with provider URL https://token.actions.githubusercontent.com and audience sts.amazonaws.com (GitHub's AWS guide, AWS: create an OIDC provider). AWS validates the JWKS endpoint's TLS certificate against its trusted root CAs and only falls back to configured thumbprints when it cannot.
2. Write the role trust policy. From AWS's GitHub section:
{
"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:octo-org/octo-repo:environment:prod"
}
}
}]
}
IAM enforces a floor here: when the GitHub provider is the trusted principal, IAM checks that token.actions.githubusercontent.com:sub is present and is not solely a wildcard or null, and rejects the policy otherwise. That floor is low. repo:octo-org/* with StringLike passes the check and still lets any repository in the organization assume the role. AWS's own guidance is to limit the condition "to a specific set of repositories or branches."
3. Use it in the workflow.
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: prod
steps:
- uses: aws-actions/configure-aws-credentials@<pinned-commit-sha>
with:
role-to-assume: arn:aws:iam::111122223333:role/deploy-prod
role-session-name: deploy-prod
aws-region: us-east-1
Prefer an environment subject for production roles, and add protection rules (required reviewers, deployment branch restrictions) to that environment. AWS "strongly recommend[s]" this when environments appear in OIDC policies.
GitHub Actions to Google Cloud
Google Cloud splits the trust into a workload identity pool (a container for external identities) and a provider (one issuer, with its mapping and condition). From Google's deployment pipeline guide:
gcloud iam workload-identity-pools create github-pool \
--location="global" --display-name="GitHub Actions"
gcloud iam workload-identity-pools providers create-oidc github \
--location="global" \
--workload-identity-pool="github-pool" \
--issuer-uri="https://token.actions.githubusercontent.com/" \
--attribute-mapping="google.subject=assertion.sub,attribute.repository_id=assertion.repository_id,attribute.repository_owner_id=assertion.repository_owner_id" \
--attribute-condition="assertion.repository_owner_id=='123456'"
- Attribute mapping uses CEL.
google.subject=assertion.subis the minimum; map any claim you will grant on. - Attribute condition is mandatory for GitHub in practice. Google states you "must use an attribute condition that restricts access to tokens issued by your GitHub organization," because the issuer is shared. Its example is
assertion.repository_owner=='ORGANIZATION'; it also warns that name-based fields can enable cybersquatting or typosquatting after a deletion and recommends the numeric*_idclaims, which is why the example above usesrepository_owner_id.
Grant access to a narrow principal set, using the project number, not the project ID:
principalSet://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github-pool/attribute.repository_id/456789
Google recommends direct resource access (grant roles on the resource to the federated principal) and falls back to service account impersonation only where an API has limitations with federated tokens. The federation overview warns that granting access to all identities in a pool "can incur risk."
In the workflow, google-github-actions/auth takes workload_identity_provider: projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/github-pool/providers/github, plus service_account only if you impersonate.
GitHub Actions to Azure
Microsoft Entra attaches a federated identity credential (FIC) to either an app registration or a user-assigned managed identity (system-assigned managed identities are not supported). Each FIC has an issuer, a subject and one audience; Entra compares them with the token's claims and they must match exactly (create trust on an app, on a managed identity).
# User-assigned managed identity
az identity federated-credential create \
--name github-prod --identity-name deploy-mi --resource-group rg-deploy \
--issuer "https://token.actions.githubusercontent.com" \
--subject "repo:octo-org/octo-repo:environment:prod" \
--audiences "api://AzureADTokenExchange"
# App registration: az ad app federated-credential create --id <app-id> --parameters credential.json
Limits and behaviors to plan around:
- 20 FICs maximum per app or user-assigned managed identity. Every branch, environment or tag you trust uses one.
- No wildcards in standard FICs. A wrong subject is accepted at creation and only fails, silently, at token exchange. Copy the subject from GitHub's documented format (note GitHub's
pull_requestuses an underscore) and confirm with a real token. - Flexible FICs (preview) add a
claimsMatchingExpression, for exampleclaims['sub'] matches 'repo:contoso/contoso-repo:ref:refs/heads/*' and claims['repository_id'] eq '456789'. They support GitHub, GitLab and Terraform Cloud tokens, and for GitHub must matchsubplusrepository_idorrepository_owner_id(flexible FICs). Azure CLI and PowerShell cannot manage them yet; use Microsoft Graph or ARM viaaz rest.
The workflow uses azure/login with client-id, tenant-id and subscription-id, which are identifiers, not secrets (GitHub's Azure guide). Scope the identity's Azure RBAC role assignment to the resource group it deploys, not the subscription.
Kubernetes workloads
Kubernetes issues projected service account tokens whose sub is system:serviceaccount:<namespace>:<service-account>, signed by the cluster's OIDC issuer. Each managed Kubernetes service wraps that differently. See the Kubernetes identity security guide for RBAC and service account hardening around this.
| Platform | Trust is configured on | Subject you scope to | Watch for |
|---|---|---|---|
| EKS IRSA | IAM OIDC provider per cluster; role trust policy | oidc.eks.REGION.amazonaws.com/id/ID:sub = system:serviceaccount:NS:SA, plus :aud = sts.amazonaws.com |
StringLike with * widens to a whole namespace |
| EKS Pod Identity | Pod Identity association (role to namespace and service account) | Role trusts pods.eks.amazonaws.com; optionally condition on aws:RequestTag/kubernetes-namespace and aws:RequestTag/kubernetes-service-account |
Credentials earlier in the SDK chain still win |
| GKE | Fixed pool PROJECT_ID.svc.id.goog |
principal://iam.googleapis.com/projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/PROJECT_ID.svc.id.goog/subject/ns/NS/sa/SA |
Same namespace and service account name in any cluster in the project is the same identity |
| AKS | FIC on a user-assigned managed identity or app | system:serviceaccount:NS:SA with issuer = cluster OIDC issuer URL |
Pod label azure.workload.identity/use: "true" is required |
EKS IRSA. Annotate the service account with eks.amazonaws.com/role-arn; the role's trust policy uses sts:AssumeRoleWithWebIdentity with StringEquals on the cluster provider's :sub and :aud (AWS IRSA setup).
EKS Pod Identity. No OIDC provider. The role trust policy allows sts:AssumeRole and sts:TagSession for the service principal pods.eks.amazonaws.com; EKS adds session tags you can condition on (Pod Identity role). The Pod Identity Agent calls AssumeRoleForPodIdentity and serves credentials through the container credential provider. AWS notes that if a workload already has credentials earlier in the SDK's default chain, those keep being used, so delete old keys after migrating (how it works).
GKE. Workload Identity Federation for GKE uses one fixed pool per project and a metadata server on each node that intercepts credential requests. Google's concept page states that "IAM doesn't distinguish between the clusters making the calls" when the namespace and service account names match, so separate untrusted clusters into separate projects or use distinct namespace names.
AKS. Enable the OIDC issuer and workload identity on the cluster (both are preconfigured on AKS Automatic), annotate the service account with azure.workload.identity/client-id, label the pod azure.workload.identity/use: "true", and create a FIC whose subject is the service account. The mutating webhook injects AZURE_FEDERATED_TOKEN_FILE; read the path from that variable rather than hard-coding it (AKS workload identity).
Common misconfigurations
| Misconfiguration | Why it is dangerous | Fix |
|---|---|---|
Wildcard subject (repo:org/*, repo:org/repo:*) |
Any repository in the org, or any branch, PR or environment in the repo, can assume a production role | Pin the exact environment or branch; use protected environments for prod |
Issuer-only trust (Google pool with no condition, or a condition on repository_owner name) |
GitHub's issuer is shared by every account; a name can be re-registered after deletion | Condition on repository_owner_id and repository_id |
| Missing or loose audience check | A token minted for another relying party can be replayed to your cloud | Require sts.amazonaws.com, api://AzureADTokenExchange or your provider's audience explicitly |
Trusting repo:org/repo:pull_request for a deploy role |
Any PR job in that repository gets the role; combined with pull_request_target or the "Send write tokens to workflows from pull requests" setting, untrusted code can run with it |
Never give PR subjects anything beyond read-only, plan-only permissions |
Over-broad role (AdministratorAccess, Owner on a subscription) |
Federation removed the stored key but not the blast radius | Least privilege per workflow; separate plan and apply roles |
Same service account name across clusters (GKE) or a wide StringLike on system:serviceaccount:ns:* (IRSA) |
A pod in a less trusted cluster or namespace inherits the identity | Separate projects; one service account per workload |
| Old access keys left in place | The attacker uses the path you forgot | Revoke, then alert on any use of the old key |
On forks specifically: GitHub reduces write permissions to read for pull_request workflows from forked repositories (workflow syntax), so a fork PR normally cannot request an OIDC token at all. The risk comes from the exceptions. pull_request_target runs in the context of the base repository with a read/write token even when triggered from a fork, and GitHub warns that running untrusted code on it "may lead to security vulnerabilities" (events reference). Do not check out and run PR code in a pull_request_target job that has id-token: write.
These failures are the federated version of secrets in repositories and CI and static API key abuse: the credential is gone, but a trust condition that is too broad gives the same result.
How this maps to SPIFFE and WIMSE
Cloud federation is an exchange at the edge; SPIFFE is a portable identity inside your estate. They meet at the issuer: SPIRE ships an OIDC Discovery Provider that serves a discovery document and JWKS so relying parties can validate JWT-SVIDs, which lets you register SPIRE as one more OIDC issuer in AWS, Google Cloud or Entra. The trust condition then pins a SPIFFE ID such as spiffe://prod.example.com/ns/payments/sa/api as the subject, the same way it pins a GitHub repository. SPIFFE/SPIRE and commercial issuers built on it, such as SPIRL, fit here.
The IETF WIMSE working group is standardizing how workload identity travels across multi-system call chains, building on SPIFFE concepts. As of 1 December 2026 none of its documents is an RFC: the HTTP signatures draft is in Area Director evaluation as a Proposed Standard, the workload identity practices draft (Informational) is waiting for Area Director go-ahead, and the architecture, identifier, mutual TLS, credentials and proof token documents are working-group drafts (WIMSE documents). The cloud federation mechanisms in this guide are generally available today and do not depend on WIMSE.
Checklist
- Inventory every stored cloud key used by CI and workloads, and pick deploy pipelines first.
- One role or identity per workflow purpose, not per organization.
- Check all three claims: issuer, an explicit audience, and an exact subject. Prefer environment subjects for production.
- Prefer immutable claims (
repository_id,repository_owner_id, the GitHub immutable subject) over names. - Protect environments with required reviewers and branch restrictions; trust the environment, not the branch.
- Grant least privilege to the federated principal, and split read-only plan from write apply.
- Pin actions to commit SHAs and keep
id-token: writeat job level, only on jobs that need it. - Never combine
pull_request_target, untrusted checkout andid-token: write. - Verify with a real token (GitHub's
actions-oidc-debuggershows the claims) and with cloud audit logs showing the federated principal. - Revoke the old static key and alert on any future key creation for that role or identity.
Related
Guides: Workload identity 101, Kubernetes identity security, non-human identity security, API key rotation automation. Glossary: workload identity federation, workload identity, OIDC, token exchange, trusted publishing, instance metadata service. Standards: OpenID Connect, WIMSE.
Frequently asked questions
- What is workload identity federation?
- Workload identity federation lets a workload exchange a signed OIDC token from the platform it runs on (GitHub Actions, a Kubernetes cluster, another cloud) for short-lived credentials in a target cloud. The cloud checks the token's issuer, audience and subject against a trust policy you configure, then returns temporary credentials. No long-lived access key or client secret is stored anywhere.
- How does GitHub Actions authenticate to AWS without access keys?
- Create an IAM OIDC identity provider for https://token.actions.githubusercontent.com with audience sts.amazonaws.com, then create a role whose trust policy allows sts:AssumeRoleWithWebIdentity and checks token.actions.githubusercontent.com:aud and token.actions.githubusercontent.com:sub. The workflow needs permissions id-token: write and uses aws-actions/configure-aws-credentials with role-to-assume. IAM refuses a trust policy for the GitHub provider that has no sub condition or only a wildcard.
- What is the difference between IRSA and EKS Pod Identity?
- IRSA (IAM roles for service accounts) uses an IAM OIDC provider per cluster: the pod gets a projected service account token and the AWS SDK calls AssumeRoleWithWebIdentity, with the trust policy checking the oidc.eks provider's sub and aud claims. EKS Pod Identity needs no OIDC provider: you create an association between a role and a service account, the role trusts the service principal pods.eks.amazonaws.com with sts:AssumeRole and sts:TagSession, and an agent on each node delivers the credentials.
- Do I need an attribute condition for GitHub in Google Cloud Workload Identity Federation?
- Yes. Google Cloud's deployment pipeline documentation says you must use an attribute condition that restricts access to tokens issued by your GitHub organization, because GitHub uses one issuer URL for every organization. It also recommends conditioning on the numeric repository_id and repository_owner_id claims rather than names, which can be reclaimed after deletion.
- Can Azure federated identity credentials use wildcards?
- Standard federated identity credentials cannot: Microsoft states wildcard characters are not supported in any property, so issuer, subject and audience must match exactly. Flexible federated identity credentials, in preview, add a claimsMatchingExpression with a matches operator for GitHub, GitLab and Terraform Cloud tokens. For GitHub, the expression must also match repository_id or repository_owner_id.
- Is workload identity federation the same as SPIFFE?
- No, but they compose. SPIFFE defines a portable workload identity (a spiffe:// ID carried in an X.509 or JWT SVID) issued after attestation. Workload identity federation is the exchange step at a cloud boundary. A SPIRE deployment can publish an OIDC discovery document and JWKS so clouds can validate its JWT-SVIDs, which lets SPIFFE be the identity and federation be how it reaches cloud APIs.
Your learning path
Before you start
Next in this learning path
Standards behind this guide
Put it into practice
- Kubernetes workload identity: EKS Pod Identity or IRSA, and GKE Workload Identity FederationRecipe
- GitHub Actions OIDC to AWS and Azure without long-lived keysRecipe
- Rotate a leaked secret properly: revoke, rotate, check usage logsRecipe
- Service Account and Non-Human Identity Policy TemplateTemplate
- Enforce SSO and disable local logins in a SaaS appRecipe
Attack techniques to know
Further reading
Related on Start with Identity
- Blog8 of 13 identity providers document AWS, Azure and Google Cloud. Only 4 document Workday
SWI's Identity Integration and Compatibility Matrix checked 20 identity platforms against their own documentation: 8 of 13 IdPs document all three clouds, 4 doc
- GuideMulti-Cloud IAM Strategy Guide: Unified Identity Across AWS, Azure, and GCP
Design a multi-cloud IAM strategy with cross-cloud identity federation, unified governance, and practical patterns for managing access across AWS, Azure, and GC
- RecipeSet up Google Cloud Workforce Identity Federation with Entra ID or Okta
Create an organization-level workforce pool, add an OIDC or SAML provider for Entra ID or Okta, map google.subject and google.groups, grant IAM roles to princip
- VendorGoogle Cloud Secret Manager
strong_contender
- BlogGoogle: LLMjacking starts with stolen cloud identities and has cost some companies $1 million
Google Threat Intelligence Group and Mandiant say LLMjacking intrusions ran up more than $100,000 in fraudulent AI charges in a day and $1 million in total at s
- GuideCertificate Lifecycle Management Guide
A complete guide to managing the certificate lifecycle, covering PKI fundamentals, certificate issuance, automated renewal, revocation strategies, monitoring fo