What Is Google Cloud Workload Identity Federation? Give External Workloads Keyless Access
Google Cloud Workload Identity Federation lets workloads outside Google Cloud, such as GitHub Actions, AWS, Azure, or an on-premises system, present an identity from an external identity provider (IdP) and obtain short-lived Google Cloud credentials without a service account key file. The important part is that trusting an external token alone is not enough: configure which issuer is trusted, how its claims map to Google identities, which organizations, repositories, or branches are allowed, and what minimum permissions the target resource grants.
Google Cloud Workload Identity Federation lets workloads outside Google Cloud, such as GitHub Actions, AWS, Azure, or an on-premises system, present an identity from an external identity provider (IdP) and obtain short-lived Google Cloud credentials without a service account key file. The important part is that trusting an external token alone is not enough: configure which issuer is trusted, how its claims map to Google identities, which organizations, repositories, or branches are allowed, and what minimum permissions the target resource grants.
This article follows official Google Cloud IAM documentation checked on November 19, 2026. It describes Workload Identity Federation for external workloads and distinguishes it from Workforce Identity Federation, which is for people such as employees and partners signing in. GitHub Actions OIDC tokens provide the example. Exact setup varies by identity provider and target Google Cloud API.
What problem does it solve?
Suppose GitHub Actions uploads a build artifact to a Google Cloud Storage bucket. A traditional setup stores a Google service account key in the repository’s secret store. That key is a long-lived secret held by an external system. If it leaks in logs or is read by an unauthorized pipeline, an attacker can reuse it until it is revoked; the key also needs rotation and cleanup.
With Workload Identity Federation, the pipeline requests an OpenID Connect (OIDC) token from GitHub. The token contains claims about the repository, the workflow identity, and sometimes the triggering event or branch. Google Cloud Security Token Service (STS) verifies that the token came from the configured provider and that its signature, issuer, audience, and conditions are acceptable. STS then returns a federated token representing the external identity. That token can receive IAM permissions directly or, when needed, be used to impersonate a service account and obtain a short-lived OAuth access token.
The flow is:
CI/CD workload → IdP OIDC token → Google STS validation and exchange
→ federated principal → resource permission (or service-account impersonation)The external workload becomes an IAM principal, so you can grant permissions and audit it as a distinct identity. The federated token does not itself grant write access to a bucket; the resource role assigned to that principal determines what the API call can do.
What do the pool, provider, attribute mapping, and condition each do?
A workload identity pool is a boundary for managing external identities. Google generally recommends separate pools for distinct non-Google Cloud environments, such as development, staging, and production. A provider inside the pool defines the trust relationship between Google Cloud and an external IdP, such as an OIDC or SAML provider, AWS, or Azure.
Claims in an external token may not yet be in the form Google Cloud IAM uses for principals. Attribute mapping translates claims in assertion into google.subject, google.groups, or custom attribute.* values. google.subject is a unique identifier for the external identity and is used in IAM bindings and Cloud Logging. Mapped attributes can form principal:// or principalSet:// identifiers when granting roles to one identity or a selected group.
An attribute condition is a Common Expression Language (CEL) expression that accepts or rejects a token. For example, checking only GitHub’s public issuer URL does not identify which GitHub organization issued a token. Restrict the condition to the trusted organization ID and repository ID, and, when required, a branch. This helps prevent an untrusted repository from using the same provider. Claims used in the condition must also be included in the provider’s attribute mapping.
Should you grant direct resource access or impersonate a service account?
Google recommends granting the federated external principal a role directly on the target resource when possible. For example, if a build pipeline only needs to upload new objects to one bucket, add the federated principal to that bucket’s IAM policy with a role such as roles/storage.objectCreator. This avoids an extra service-account identity and makes it easier to see which federated principal accessed the resource. objectCreator is only an example for creating new objects; choose separate permissions if the workload must read, list, update, or delete objects.
Some Google Cloud APIs have limitations for direct federated access. If an application requires a service-account identity, or the API does not support direct federation for the operation, consider service account impersonation. In that model, grant the federated principal roles/iam.workloadIdentityUser on the target service account, then grant that service account only the required resource permissions. A dedicated service account per application helps keep one workload’s permissions from accumulating in a shared account.
| Option | Benefit | Consideration |
|---|---|---|
| Grant the federated principal direct resource access | Connects identity directly to resource permissions; avoids an additional service-account permission set | Check API-specific support and construct the pool principal identifier correctly |
| Impersonate a service account | Can work with tools or APIs that expect a service-account identity | Requires managing both impersonation permission and the service account’s resource roles |
A basic GitHub Actions setup flow
The example is a hypothetical workflow that uploads new objects to a test bucket. Before configuring it, check your project, repository, IdP claim names, and support for the target API. ORG_ID, REPO_ID, PROJECT_NUMBER, and POOL_ID below are placeholders.
Define the trust and permission boundary. Specify which GitHub organization, repository, and branch may authenticate, and what operations are needed on which bucket. Pool and provider IDs cannot be changed after creation, so choose a naming scheme first. You can manage pools and providers in a separate project from the resource project.
Register an OIDC provider. Create a workload identity pool in Google Cloud and add a provider for GitHub Actions with issuer
https://token.actions.githubusercontent.com/. Map the token’ssubclaim togoogle.subjectand map the owner ID, repository ID, and branch claims used in your condition. For example:google.subject=assertion.sub attribute.repository_owner_id=assertion.repository_owner_id attribute.repository_id=assertion.repository_id attribute.ref=assertion.refRestrict access to the organization, repository, and branch. Do not trust the issuer alone. Require the trusted owner ID and repository ID, and for production deployments, the allowed branch or environment. For example:
assertion.repository_owner_id=='ORG_ID' && assertion.repository_id=='REPO_ID' && assertion.ref=='refs/heads/main'GitHub name-based claims such as
repositoryorrepository_ownercan be reused if a repository or organization is deleted. Following Google’s security guidance, prefer numeric ID claims that cannot be reused, and verify that the actual token contains them.Grant the narrowest resource role. With direct access, add only the principal set whose
Exact CLI options for creating pools and providers, token-request settings, and claim names vary by provider. The sequence above explains the components and checks; it does not claim that commands or settings were run in a real project. Google’s pipeline guide has provider-specific examples for GitHub Actions, GitLab, Azure DevOps, and Terraform.
How should you troubleshoot common failures?
If token exchange is rejected, start with the error and check these items in order:
**Issuer and audience:** Confirm the token’s `iss` matches the provider’s issuer URL and that its audience is allowed by the provider.
**Attribute mapping and condition:** Ensure every claim referenced in a condition is mapped, and compare the condition with the token’s actual values. A wrong organization, repository, or branch value causes rejection.
**IAM principal identifier:** For direct access, check the pool ID, mapped attribute, and project number in the binding. Project ID and project number are not interchangeable.
**Target resource role:** If STS issued a token but the API denies the request, confirm that the external principal has the required role on the target resource. For service-account impersonation, check both `roles/iam.workloadIdentityUser` and the service account’s role on the target resource.
**API-specific support:** If only a particular product or API method fails, check its current federation support and limitations. For an API that restricts direct federation, impersonating a dedicated service account may be an alternative.
Security boundaries and operational cautions
An IdP-signed token does not mean every identity from that IdP should be trusted. The provider verifies the issuer; attribute mappings decide which claims become Google IAM identities; conditions narrow which organizations and workloads are accepted. Broad settings can allow unrelated teams or repositories to authenticate through the same pool. Do not grant access to every pool member when only specific subjects or attribute sets are needed.
If you use service-account impersonation, restrict both which external identities can impersonate an account and which resources that account can access. Prefer application-specific service accounts and review unused accounts and roles. Choose unique, stable attributes: mutable or reusable names can cause identity ambiguity or allow another workload to map to the same principal. Also restrict who can change provider configuration.
Workload Identity Federation removes the need to store and rotate a service account key, but it does not replace IAM design, token-condition checks, logging, or resource permission management. Precisely constrain trusted identities in pool/provider conditions, prefer direct resource access when supported, and use a dedicated least-privilege service account if impersonation is needed.
References
[Google Cloud Workload Identity Federation: pools, providers, and attribute mappings](https://cloud.google.com/iam/docs/workload-identity-federation)
[Security best practices for Workload Identity Federation](https://cloud.google.com/iam/docs/best-practices-for-using-workload-identity-federation)
[Federation setup for GitHub Actions and other deployment pipelines](https://cloud.google.com/iam/docs/workload-identity-federation-with-deployment-pipelines)
[Product support and limitations for identity federation](https://cloud.google.com/iam/docs/federated-identity-supported-services)
[Choosing workload authentication for the gcloud CLI](https://cloud.google.com/sdk/docs/authenticate)