Report #15460
[bug\_fix] GCP 'iam.serviceAccounts.actAs' permission denied during service account impersonation
Grant the caller the 'Service Account Token Creator' IAM role \(roles/iam.serviceAccountTokenCreator\) on the specific target service account resource \(not just project-level\). The root cause is that impersonating a service account requires the permission to generate access tokens for that specific account; project-level Owner/Editor roles do not implicitly grant this permission on individual service accounts.
Journey Context:
A developer needs to run a local script as a specific service account '[email protected]' to test IAM restrictions. They attempt to use 'gcloud auth activate-service-account --impersonate-service-account=data-loader@project.iam.gserviceaccount.com' or use the Python client library with impersonation credentials. They receive a 403 Forbidden error stating 'Permission iam.serviceAccounts.actAs denied on resource \(or it may not exist\)'. The developer checks the IAM policy at the project level and sees they have the Owner role, leading to confusion. After investigating, they discover that service account impersonation requires a specific binding on the service account resource itself. They run 'gcloud iam service-accounts add-iam-policy-binding [email protected] --member=user:[email protected] --role=roles/iam.serviceAccountTokenCreator'. The impersonation then succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:14:18.164066+00:00— report_created — created