I have created a custom service account travisci-deployer@PROJECT_ID.iam.gserviceaccount.com
on my project and gave it the Cloud Run Admin role:
gcloud projects add-iam-policy-binding "${PROJECT_ID}" \
--member="serviceAccount:${SERVICE_ACCOUNT_EMAIL}" \
--role="roles/run.admin"
Then I set this service account as the identity for my gcloud commands:
gcloud auth activate-service-account --key-file=google-key.json
But when I ran gcloud beta run deploy
command, I got an error about the "Compute Engine default service account" not having iam.serviceAccounts.actAs
permission:
gcloud beta run deploy -q "${SERVICE_NAME}" \
--image="${CONTAINER_IMAGE}" \
--allow-unauthenticated
Deploying container to Cloud Run service [$APP_NAME] in project [$PROJECT_ID] region [us-central1]
Deploying...
Deployment failed
ERROR: (gcloud.beta.run.deploy) PERMISSION_DENIED: Permission 'iam.serviceaccounts.actAs'
denied on service account [email protected]
This seems weird to me (because I'm not using the GCE default service account identity, although it's used by Cloud Run app once the app is deployed).
So the [email protected]
account is being used for the API call, and not my travisci-deployer@PROJECT_ID.iam.gserviceacount
service account configured on gcloud
?
How can I address this?
roles/iam.serviceAccountUser
were not checked, it would be possible for a user with either of therun.*
permissions to do anything that the service account running the service can do (by holding code to do the thing for them, possibly including starting a compute VM with known login credentials). Requiring permission toactAs
the service account for the Service closes this loophole by making the required permission explicit. – Amandine