Switch to Workload Identity Federation

In this guide, you will move an existing GCP organization connection from Service Account Impersonation to Workload Identity Federation (WIF) — keyless authentication, where no service account keys are created, stored, or rotated. Along the way you will also make the connection ready for Guardrails TE v5.59.0 or higher, which changes how GCP API quota is attributed.

You reuse the same service account, its existing organization roles, and your guardrails_external_id label throughout. You only add a trust relationship and one policy — there is no new service account and no re-import.

This guide is for organizations already connected via impersonation. To connect a new organization with WIF, see Set Up Workload Identity Federation instead.

[!NOTE] Step 1 applies to every GCP connection on TE v5.59.0 or higher, even if you stay on Service Account Impersonation. Steps 2 onward are the switch to WIF.

Prerequisites

Step 1: Grant the Service Usage Consumer Role

Starting in Guardrails TE v5.59.0, each GCP API call's quota is billed to the specific project being scanned rather than to one shared project. This spreads API usage evenly, so a single busy project cannot throttle monitoring across your whole organization.

For this to work, your service account needs the serviceusage.services.use permission on each project. Without it, project-level controls (CMDB and Event Pollers) begin to fail after you upgrade:

[!CAUTION] Caller does not have required permission to use project <name>. Grant the caller the roles/serviceusage.serviceUsageConsumer role, or a custom role with the serviceusage.services.use permission…

This affects every GCP connection on TE v5.59.0 or higher, regardless of how it authenticates — so complete this step whether or not you continue to WIF.

Grant roles/serviceusage.serviceUsageConsumer to your existing service account at the organization level, so it applies to every current and future project:

gcloud organizations add-iam-policy-binding <YOUR_GCP_ORG_ID> \
  --member="serviceAccount:<ORG_SA_EMAIL>" \
  --role="roles/serviceusage.serviceUsageConsumer"

Grant this before you upgrade to TE v5.59.0 (recommended), or as soon as possible afterward. Controls that errored during the upgrade recover on their own once the permission propagates — usually a few minutes.

[!TIP] serviceUsageConsumer is part of the recommended read-only role set for a GCP connection — see Set Up Service Account Authentication for the full list, and API Quota Distribution for more on how per-project quota works.

Step 2: Create a Workload Identity Pool

Run this in your service account's host project. The pool is the trust boundary that lets an external (AWS) identity authenticate to GCP.

gcloud iam workload-identity-pools create turbot-guardrails-pool \
  --project="<SA_HOST_PROJECT_ID>" \
  --location="global" \
  --display-name="Turbot Guardrails Pool"

Step 3: Add an AWS Provider

Add an AWS provider to the pool. The --attribute-condition restricts federation to only Guardrails' dedicated WIF role, so no other AWS identity is accepted.

gcloud iam workload-identity-pools providers create-aws turbot-guardrails-aws \
  --project="<SA_HOST_PROJECT_ID>" \
  --location="global" \
  --workload-identity-pool="turbot-guardrails-pool" \
  --account-id="<GUARDRAILS_AWS_ACCOUNT_ID>" \
  --attribute-condition="assertion.arn.startsWith('arn:<GUARDRAILS_AWS_PARTITION>:sts::<GUARDRAILS_AWS_ACCOUNT_ID>:assumed-role/<GUARDRAILS_WIF_ROLE_NAME>/')"

<GUARDRAILS_AWS_PARTITION> is aws for Guardrails running in commercial AWS regions, or aws-us-gov for Guardrails running in AWS GovCloud (US). If the partition doesn't match, GCP rejects Guardrails' credentials with The given credential is rejected by the attribute condition.

Step 4: Grant the Pool Access to Your Service Account

This is the only new IAM grant. It lets the federated AWS identity act as your existing service account — so you keep the same identity and permissions, and only change how Guardrails authenticates to it.

First, get your host project's number (not its ID):

gcloud projects describe <SA_HOST_PROJECT_ID> --format='value(projectNumber)'

Then grant the binding on your existing service account:

gcloud iam service-accounts add-iam-policy-binding <ORG_SA_EMAIL> \
  --project="<SA_HOST_PROJECT_ID>" \
  --role="roles/iam.workloadIdentityUser" \
  --member="principalSet://iam.googleapis.com/projects/<SA_HOST_PROJECT_NUMBER>/locations/global/workloadIdentityPools/turbot-guardrails-pool/*"

Step 5: Get the Pool Provider Resource Name

Assemble your Pool Provider Resource Name — you will enter it into Guardrails in the next step:

projects/<SA_HOST_PROJECT_NUMBER>/locations/global/workloadIdentityPools/turbot-guardrails-pool/providers/turbot-guardrails-aws

Step 6: Update the Connection in Guardrails

  1. In the Guardrails console, open your GCP Organization connection.
  2. Select Policies.
  3. Find the Workload Identity Pool Provider policy.
  4. Set its value to the Pool Provider Resource Name from Step 5 and save.

Guardrails starts using WIF for this organization immediately, and it applies to every project underneath. Nothing is re-imported.

[!NOTE] To roll back to Service Account Impersonation at any time, remove the Workload Identity Pool Provider policy. The connection reverts immediately — as long as you have not completed the optional Step 8.

Step 7: Verify the Switch

Re-run a few of the organization's controls, or wait for their next scheduled run, and confirm they stay healthy. Because WIF uses the same service account — with the same roles — nothing else needs to change. A successful control run confirms the full path: Guardrails federates through the pool, impersonates your service account, and reads your GCP resources.

You're done when the organization's controls return to (or remain) OK, with no serviceusage.services.use or federation errors.

Step 8: Remove the Old Impersonation Grant (Optional)

Once WIF is confirmed working, you can retire the key-based path entirely: remove the Service Account Token Creator role that Guardrails' master service account held on your organization service account. After this, Guardrails authenticates only through WIF.

[!CAUTION] This removes the quick rollback described in Step 6, so only do it once you are confident WIF is working.

Next Steps

Troubleshooting

IssueDescriptionResolution
Controls fail with a serviceusage.services.use errorThe service account cannot use the scanned project's APIs — required on TE v5.59.0+.Complete Step 1 to grant serviceUsageConsumer at the organization level.
Controls fail after switching to WIFThe WIF transit role may not be available for your workspace (self-hosted), or the pool provider value is incorrect.Confirm WIF is enabled (SaaS: automatic; self-hosted: deployed via TEF), and that the Workload Identity Pool Provider policy matches the value from Step 5. Roll back by removing the policy.
Invalid Workload Identity Pool Provider formatThe value does not match the expected resource-name format.Re-check the value assembled in Step 5: projects/{number}/locations/global/workloadIdentityPools/{pool}/providers/{provider}.
Further assistanceNeed help?Open a Support Ticket