Cross project management using service account

2019-01-14 16:30发布

I need a service account that can access multiple projects, but I have not been able to find a way to do this at all. It seems that a service account is always bound to a project.

Another option is to create a service account on the separate projects and then authenticate them using gcloud auth activate-service-account --key-file SOME_FILE.json, but the problem here is that it does not seem possible to automate the creation of service accounts.

So the question is then: Is it possible to create a cross project service account or to automate the creation of a service accounts? Even better would be if I could do both

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-01-14 17:09

I know its a bit old, but if anyone is still looking for this,To add to @Zachary Newman answer, To make things clear, After you created a service account in project A you should go to project B to "IAM" (not "Service Accounts"), There you will be able to add the email you just created with proper roles.

查看更多
倾城 Initia
3楼-- · 2019-01-14 17:15

You should be able to add a service account to another project:

  1. Create the first service account in project A in the Cloud Console. Activate it using gcloud auth activate-service-account.

  2. In the Cloud Console, navigate to project B. Find the "IAM & admin" > "IAM" page. Click the "Add" button. In the "New members" field paste the name of the service account (it should look like a strange email address) and give it the appropriate role.

  3. Run gcloud commands with --project set to project B. They should succeed (I just manually verified that this will work).

Automatic creation of service accounts is something that we're hesitant to do until we can work through all of the security ramifications.

查看更多
登录 后发表回答