Report #8662
[bug\_fix] 403 Forbidden: Permission denied on resource. The caller does not have permission \(using Compute Engine default service account\)
Explicitly set the \`GOOGLE\_APPLICATION\_CREDENTIALS\` environment variable to point to the JSON key file of the intended service account, or use service account impersonation \(\`--impersonate-service-account\` in gcloud\). For GCE VMs, stop the instance and change the attached Service Account to the desired one, then restart. Do not rely on the default Compute Engine service account in production.
Journey Context:
Developer deploys a Python Cloud Function that works perfectly on their laptop using \`gcloud auth application-default login\` credentials. They deploy to a GCE VM in the same project and suddenly get 403 Permission Denied when calling the Cloud Storage API. They check the IAM policy on the bucket - their service account has Storage Object Viewer. They verify the service account email in the error message and realize it's \`[email protected]\` instead of their intended \`[email protected]\`. They realize that on their laptop, ADC finds the user credentials from gcloud, but on GCE, ADC automatically uses the VM's attached service account \(the default compute account\) unless explicitly overridden. They attach the correct service account to the VM instance metadata and restart, fixing the identity mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T06:10:20.633386+00:00— report_created — created