Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud Service Account with 'roles/container.admin'

I am trying to create a Service Account with 'roles/container.admin' and i get an error saying that the role is not supported for this resource.

$ gcloud iam service-accounts add-iam-policy-binding [email protected] --member='serviceAccount:[email protected]' --role='roles/container.admin'

ERROR: (gcloud.iam.service-accounts.add-iam-policy-binding) INVALID_ARGUMENT: Role roles/container.admin is not supported for this resource.

If I create a Service Account from the CONSOLE UI I can add this role without a problem.

like image 208
Victor Rosales Avatar asked Dec 06 '17 16:12

Victor Rosales


2 Answers

You have to use gcloud projects to add roles for a service account at a project level as shown here.

This works for me:

gcloud projects add-iam-policy-binding PROJECT_ID \ 
--member serviceAccount:[email protected] \
--role roles/container.admin
like image 87
Guillem Xercavins Avatar answered Sep 29 '22 18:09

Guillem Xercavins


I got the same error. You have to give the absolute path to the role.

cloud iam service-accounts add-iam-policy-binding SERVICEACCOUNT --member=SERVICEACCOUNT_EMAIL --role=projects/PROJECTNAME/roles/ROLENAME

like image 36
Vinayak Kaushik Avatar answered Sep 29 '22 20:09

Vinayak Kaushik