# Workload identity federation: setup for AWS, Google Cloud, Azure and Kubernetes

Source: https://startwithidentity.com/guides/machine-identity/workload-identity-federation-guide/
Last updated: 2026-12-01
License: content by Start with Identity. Cite the source URL.

---

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](https://startwithidentity.com/guides/machine-identity/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

1. **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.
2. **The workload sends it to the cloud's token service.** AWS STS, Google Cloud STS (which follows OAuth 2.0 [token exchange](https://startwithidentity.com/glossary/token-exchange/), RFC 8693) or the Microsoft identity platform.
3. **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?
4. **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](https://docs.github.com/en/actions/reference/security/oidc), 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 example `repo: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 `aud` to the URL of the repository owner unless the action requests a custom audience. The official cloud actions request `sts.amazonaws.com` (AWS) and `api://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](https://docs.github.com/en/actions/reference/security/oidc) 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](https://docs.github.com/en/actions/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services), [AWS: create an OIDC provider](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_providers_create_oidc.html)). 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](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-idp_oidc.html#idp_oidc_Create_GitHub):

```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: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.**

```yaml
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](https://docs.cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines):

```bash
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.sub` is 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 `*_id` claims, which is why the example above uses `repository_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](https://docs.cloud.google.com/iam/docs/workload-identity-federation) 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](https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust), [on a managed identity](https://learn.microsoft.com/en-us/entra/workload-id/workload-identity-federation-create-trust-user-assigned-managed-identity)).

```bash
# 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_request` uses an underscore) and confirm with a real token.
- **Flexible FICs** (preview) add a `claimsMatchingExpression`, for example `claims['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 match `sub` plus `repository_id` or `repository_owner_id` ([flexible FICs](https://learn.microsoft.com/en-us/entra/workload-id/workload-identities-flexible-federated-identity-credentials)). Azure CLI and PowerShell cannot manage them yet; use Microsoft Graph or ARM via `az rest`.

The workflow uses `azure/login` with `client-id`, `tenant-id` and `subscription-id`, which are identifiers, not secrets ([GitHub's Azure guide](https://docs.github.com/en/actions/how-tos/secure-your-work/security-harden-deployments/oidc-in-azure)). 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](https://startwithidentity.com/guides/machine-identity/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](https://docs.aws.amazon.com/eks/latest/userguide/associate-service-account-role.html)).

**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](https://docs.aws.amazon.com/eks/latest/userguide/pod-id-role.html)). 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](https://docs.aws.amazon.com/eks/latest/userguide/pod-id-how-it-works.html)).

**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](https://docs.cloud.google.com/kubernetes-engine/docs/concepts/workload-identity) 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](https://learn.microsoft.com/en-us/azure/aks/workload-identity-overview)).

## 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](https://docs.github.com/en/actions/reference/workflows-and-actions/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](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows)). 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](https://startwithidentity.com/techniques/secrets-in-repositories-and-ci/) and [static API key abuse](https://startwithidentity.com/techniques/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](https://startwithidentity.com/glossary/spiffe/) is a portable identity inside your estate. They meet at the issuer: SPIRE ships an [OIDC Discovery Provider](https://github.com/spiffe/spire/blob/main/support/oidc-discovery-provider/README.md) 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](https://startwithidentity.com/vendors/machine-identity/spiffe-spire/) and commercial issuers built on it, such as [SPIRL](https://startwithidentity.com/vendors/machine-identity/spirl/), fit here.

The IETF [WIMSE](https://startwithidentity.com/standards/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](https://datatracker.ietf.org/wg/wimse/documents/)). The cloud federation mechanisms in this guide are generally available today and do not depend on WIMSE.

## Checklist

1. **Inventory** every stored cloud key used by CI and workloads, and pick deploy pipelines first.
2. **One role or identity per workflow purpose**, not per organization.
3. **Check all three claims:** issuer, an explicit audience, and an exact subject. Prefer environment subjects for production.
4. **Prefer immutable claims** (`repository_id`, `repository_owner_id`, the GitHub immutable subject) over names.
5. **Protect environments** with required reviewers and branch restrictions; trust the environment, not the branch.
6. **Grant least privilege** to the federated principal, and split read-only plan from write apply.
7. **Pin actions to commit SHAs** and keep `id-token: write` at job level, only on jobs that need it.
8. **Never** combine `pull_request_target`, untrusted checkout and `id-token: write`.
9. **Verify** with a real token (GitHub's `actions-oidc-debugger` shows the claims) and with cloud audit logs showing the federated principal.
10. **Revoke** the old static key and alert on any future key creation for that role or identity.

## Related

Guides: [Workload identity 101](https://startwithidentity.com/guides/machine-identity/workload-identity-101/), [Kubernetes identity security](https://startwithidentity.com/guides/machine-identity/kubernetes-identity-security-guide/), [non-human identity security](https://startwithidentity.com/guides/machine-identity/non-human-identity-security/), [API key rotation automation](https://startwithidentity.com/guides/machine-identity/api-key-rotation-automation-guide/). Glossary: [workload identity federation](https://startwithidentity.com/glossary/workload-identity-federation/), [workload identity](https://startwithidentity.com/glossary/workload-identity/), [OIDC](https://startwithidentity.com/glossary/oidc/), [token exchange](https://startwithidentity.com/glossary/token-exchange/), [trusted publishing](https://startwithidentity.com/glossary/trusted-publishing/), [instance metadata service](https://startwithidentity.com/glossary/instance-metadata-service/). Standards: [OpenID Connect](https://startwithidentity.com/standards/openid-connect/), [WIMSE](https://startwithidentity.com/standards/wimse/).
