GCP: `Permission 'iam.serviceAccounts.getAccessToken' denied on resource (or it may not exist).`
AdvancedTroubleshootingOIDC & Cloud Authentication
Answer
Likely causes → The workload identity principal lacks roles/iam.workloadIdentityUser on the service account, the attribute mapping does not produce the attribute used in the binding, or the attribute condition rejected the token.
Diagnose →
gcloud iam service-accounts get-iam-policy [email protected]
gcloud iam workload-identity-pools providers describe github --workload-identity-pool=github-pool --location=global
Fix →
gcloud iam service-accounts add-iam-policy-binding [email protected] \
--role roles/iam.workloadIdentityUser \
--member "principalSet://iam.googleapis.com/projects/123456/locations/global/workloadIdentityPools/github-pool/attribute.repository/devopsshack/shack-api"
Prevent → Keep pool, provider and bindings in Terraform.
More on OIDC & Cloud Authentication
`Error: Could not assume role with OIDC: Not authorized to perform sts:AssumeRoleWithWebIdentity`Advanced`Error: Credentials could not be loaded, please check your action inputs: Could not load credentials from any providers`Intermediate`Error: Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable`BeginnerOIDC works on `main` but fails on a tag-triggered release workflow.Intermediate`An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation: Incorrect token audience`Intermediate`No OpenIDConnect provider found in your account for https://token.actions.githubusercontent.com`Beginner