Interview Prep/GitHub Actions/OIDC & Cloud Authentication

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.

All GitHub Actions questions Roadmap: GitHub Actions

More on OIDC & Cloud Authentication