Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you enable "iam.serviceAccounts.actAs" permissions on a sevice account?

I am trying to deploy a service with a non-default service account by following this guide and it says I need "the iam.serviceAccounts.actAs permission on the service account being deployed". The service account I am using is @cloudbuild.gserviceaccount.com, but I don't see the option to add it on my project's Permissions page.

like image 228
sdfsdf Avatar asked Apr 21 '20 01:04

sdfsdf


People also ask

How do I enable IAM serviceAccounts in Actas?

In the console, go to the IAM page, find the service accounts, and review their roles. If necessary, grant a less permissive role to the service account. You can select a role from the list of IAM predefined roles, use a role suggested by a role recommendation, or create a custom role.

Can you generate access keys for service accounts?

You can create a service account key using the console, the gcloud CLI, the serviceAccounts. keys. create() method, or one of the client libraries. A service account can have up to 10 keys.


Video Answer


2 Answers

The key point is that the service account is a resource. You need to add an IAM role for your identity to the service account (the resource). This grants you permissions on the resource (service account).

  • Open the Google Cloud Console. Go to IAM & Admin -> Service accounts.

  • Find the service account. Tick the box to the left of the service account.

  • In the right-hand "Permissions" panel, click ADD MEMBER

  • Add your IAM member email address. For the role select Service Accounts -> Service Account User.

  • Click Save

You can also you the CLI:

gcloud iam service-accounts add-iam-policy-binding [SERVICE_ACCOUNT] --member [MEMBER_EMAIL] --role roles/iam.serviceAccountUser

gcloud iam service-accounts add-iam-policy-binding

like image 95
John Hanley Avatar answered Oct 21 '22 15:10

John Hanley


On the service account you are using, you need to give yourself the role of Service Account User.

Go to IAM -> Service Accounts -> (Your service Account) -> Permissions -> Grant Access

(By doing this you are granting yourself access to use this service account)

See also:

  • Unable to create a new Cloud Function - cloud-client-api-gae
  • Cloud Build fails to deploy to Google App Engine - You do not have permission to act as @appspot.gserviceaccount.com
like image 1
Sander van den Oord Avatar answered Oct 21 '22 15:10

Sander van den Oord