Workload Identity Federation and CI Logins
Workloads outside the cloud (a GitHub Actions job, a GitLab pipeline, a Kubernetes pod, a workload in another cloud) can't use an attached identity. The modern answer on all three clouds is the same: the workload already has an OIDC token from its own platform; the cloud is configured to trust that issuer for specific claims and swaps the token for short-lived cloud credentials. No stored secrets.
On AWS this is… an IAM OIDC identity provider plus a role whose trust policy checks
token.actions.githubusercontent.com:sub, used byaws-actions/configure-aws-credentials, as in GitHub Actions security. In EKS, IRSA or EKS Pod Identity.
The three trust objects
| AWS | Azure | Google Cloud | |
|---|---|---|---|
| Trust the issuer | IAM OIDC provider | federated identity credential on an app registration or a user-assigned managed identity | workload identity pool + provider |
| Match the workload | trust policy conditions on sub, aud (wildcards with StringLike) |
issuer + exact subject + audience api://AzureADTokenExchange |
--attribute-mapping + a CEL --attribute-condition; bindings on principal:// / principalSet:// identifiers |
| What the workload becomes | the assumed role | the app's service principal / the managed identity | the federated principal directly, or an impersonated service account |
| Kubernetes flavour | IRSA, EKS Pod Identity | Microsoft Entra Workload ID on AKS | Workload Identity Federation for GKE |
The matching rules are the difference to remember. AWS lets you write repo:acme/shop:* with StringLike. A classic Azure federated credential matches the subject exactly: one credential per branch, environment or tag pattern you want to trust (a newer "flexible" form with expressions exists, but check its availability before relying on it). Google Cloud maps claims into attributes and lets you write any CEL condition over them.
GitHub Actions to each cloud
The job needs permissions: id-token: write, then one login step per cloud:
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v7
- uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: arn:aws:iam::111122223333:role/gha-deploy
aws-region: eu-west-1
- uses: azure/login@v3
with:
client-id: ${{ vars.AZURE_CLIENT_ID }}
tenant-id: ${{ vars.AZURE_TENANT_ID }}
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
- uses: google-github-actions/auth@v3
with:
workload_identity_provider: projects/123456789012/locations/global/workloadIdentityPools/github/providers/acme
service_account: deployer@shop-prod-4821.iam.gserviceaccount.comThe IDs are not secrets (they identify, they don't authenticate), so repository variables are fine. Action major versions move; check each action's README for the current one.
Setting up the trust
Azure, sample session: trust jobs that use the production environment of acme/shop, on a user-assigned managed identity.
az identity create -g rg-shop-ci -n id-gha-deploy
az identity federated-credential create \
--name gha-shop-production \
--identity-name id-gha-deploy --resource-group rg-shop-ci \
--issuer https://token.actions.githubusercontent.com \
--subject repo:acme/shop:environment:production \
--audience api://AzureADTokenExchange
# then: az role assignment create ... for the identity's principal ID at the scope it deploys toGoogle Cloud, sample session: a pool, a GitHub provider limited to one organization, and a binding for one repository.
gcloud iam workload-identity-pools create github --location=global --display-name="GitHub Actions"
gcloud iam workload-identity-pools providers create-oidc acme \
--location=global --workload-identity-pool=github \
--issuer-uri="https://token.actions.githubusercontent.com" \
--attribute-mapping="google.subject=assertion.sub,attribute.repository=assertion.repository,attribute.environment=assertion.environment" \
--attribute-condition="assertion.repository_owner=='acme'"
gcloud iam service-accounts add-iam-policy-binding deployer@shop-prod-4821.iam.gserviceaccount.com \
--role=roles/iam.workloadIdentityUser \
--member="principalSet://iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/github/attribute.repository/acme/shop"Identifiers use the project number, not the project ID. And always set an attribute condition on a provider for a shared issuer like GitHub's: without one, any repository on GitHub could present a valid token to your pool.
Model: whose token gets in?
The three clouds see the same GitHub token claims. This model applies each cloud's matching rule:
from fnmatch import fnmatchcase
tokens = [
{"sub": "repo:acme/shop:environment:production", "repository": "acme/shop",
"repository_owner": "acme", "environment": "production"},
{"sub": "repo:acme/shop:ref:refs/heads/feature-x", "repository": "acme/shop",
"repository_owner": "acme", "environment": None},
{"sub": "repo:evil/shop:environment:production", "repository": "evil/shop",
"repository_owner": "evil", "environment": "production"},
]
def aws(t): # trust policy: StringLike on sub
return fnmatchcase(t["sub"], "repo:acme/shop:*")
def azure(t): # federated credential: exact subject match
return t["sub"] == "repo:acme/shop:environment:production"
def gcp(t): # provider condition + binding on attribute.repository
if t["repository_owner"] != "acme":
return False # rejected by the provider's attribute condition
return t["repository"] == "acme/shop"
print(f"{'subject':<42}{'AWS':<6}{'Azure':<7}GCP")
for t in tokens:
yn = lambda ok: "yes" if ok else "no"
print(f"{t['sub']:<42}{yn(aws(t)):<6}{yn(azure(t)):<7}{yn(gcp(t))}")subject AWS Azure GCP
repo:acme/shop:environment:production yes yes yes
repo:acme/shop:ref:refs/heads/feature-x yes no yes
repo:evil/shop:environment:production no no no
The feature branch gets in on AWS and Google Cloud because those rules trust the whole repository, and not on Azure because the subject must match exactly. For production deploys, the Azure behaviour is what you want everywhere: tighten the AWS condition to repo:acme/shop:environment:production and bind the Google Cloud role on attribute.environment/production or a combined attribute, so a feature branch can't deploy to production.
Kubernetes pods
The same idea runs inside AKS and GKE: the cluster is an OIDC issuer, the pod's Kubernetes ServiceAccount token is the credential.
# AKS: Microsoft Entra Workload ID
apiVersion: v1
kind: ServiceAccount
metadata:
name: shop-api
namespace: shop
annotations:
azure.workload.identity/client-id: 1b2c3d4e-0000-4000-8000-0a1b2c3d4e5f # the managed identity's client ID
---
# and in the pod template: labels: {azure.workload.identity/use: "true"}, serviceAccountName: shop-apiOn AKS, enable it with az aks create|update --enable-oidc-issuer --enable-workload-identity, then create a federated credential with subject system:serviceaccount:shop:shop-api and the cluster's issuer URL (az aks show --query oidcIssuerProfile.issuerUrl).
On GKE (always on in Autopilot; --workload-pool=PROJECT_ID.svc.id.goog on Standard clusters), grant roles straight to the Kubernetes ServiceAccount's principal, no annotation needed:
gcloud projects add-iam-policy-binding shop-prod-4821 --role=roles/cloudsql.client \
--member="principal://iam.googleapis.com/projects/123456789012/locations/global/workloadIdentityPools/shop-prod-4821.svc.id.goog/subject/ns/shop/sa/shop-api"The older GKE pattern, binding roles/iam.workloadIdentityUser on a Google service account to serviceAccount:PROJECT_ID.svc.id.goog[shop/shop-api] and annotating the Kubernetes ServiceAccount with iam.gke.io/gcp-service-account, still works and is needed for the few APIs that don't accept federated principals.
Test yourself
How does a classic Azure federated identity credential match a GitHub Actions token?
- Wildcards on sub
- Exact match on issuer, subject and audience
- Any token from GitHub
- By repository owner only
Why must a Google Cloud workload identity provider for GitHub have an attribute condition?
- It is required syntax only
- Without one, tokens from any GitHub repository could be exchanged in your pool
- To save cost
- GitHub tokens have no claims
What is the AKS feature that lets pods use a managed identity through their Kubernetes ServiceAccount token?
- Pod identity v1
- Microsoft Entra Workload ID
- Azure Policy
- Key Vault references