The reason @mans123 solution above worked for him is because the principal has the crucial Editor role shown in his screenshot.
My experiments show that the principal which Python uses needs to have the iam.serviceAccounts.actAs permission to impersonate the SA (let’s call it SA #1). Now, when “you” are launching Python from a GCP VM (e.g., a Vertex AI Workbench Instance), “you” are NOT your user principal (i.e., your email address); rather, “you” have impersonated the VM’s underlying SA (let’s call it SA #2). So, SA#2 must have the iam.serviceAccounts.actAs permission to impersonate SA #1.
Add another twist: if SA #1 and #2 are the same SA, then that SA needs iam.serviceAccounts.actAs permission on itself. Such a need is evidenced from this informational Cloud Logging record:
{
"protoPayload": {
...
"authenticationInfo": {
"principalEmail": "my-vertex-ai-workbench-sa@my-xxx-prj.iam.gserviceaccount.com"
},
...
"methodName": "iam.serviceAccounts.actAs",
...
"request": {
"@type": "type.googleapis.com/CanActAsServiceAccountRequest",
...
},
...
Without granting the “self-impersonating” permission, I got the following error. As you see, the **authenticationInfo.**principalEmail (SA #1) is trying to impersonate the
**request.****pipelineJob.**serviceAccount (SA #2) – in my case, the 2 SAs are the same SA.
{
"protoPayload": {
"status": {
...
"message": "You do not have permission to act as service_account: my-vertex-ai-workbench-sa@my-xxx-prj.iam.gserviceaccount.com. (or it may not exist)."
},
"authenticationInfo": {
"principalEmail": "my-vertex-ai-workbench-sa@my-xxx-prj.iam.gserviceaccount.com",
...
},
...
"methodName": "google.cloud.aiplatform.v1.PipelineService.CreatePipelineJob",
...
"request": {
"pipelineJob": {
"serviceAccount": "my-vertex-ai-workbench-sa@my-xxx-prj.iam.gserviceaccount.com"
},
...
},
...
So, the solution is simple:
- Grant the IAM role Service Account User (roles/iam.serviceAccountUser) from SA #1 to SA #2. If they are the same SA, then grant to itself (yeah, a bit twisted.)