Reputation: 22234
Which GCP SDK command to use to add a Google account (email) to a GCP project?
From the UI, it is possible.
However, gcloud iam command nor gcloud projects do not have an option.
Upvotes: 0
Views: 3115
Reputation: 4461
I post this community wiki answer to make the solution provided at the comment section more visible. Feel free to edit or expand.
As it was suggested by @Joachim Isaksson at the comment section, you should use the command gcloud projects add-iam-policy-binding
:
Adds a policy binding to the IAM policy of a project, given a project ID and the binding. One binding consists of a member, a role, and an optional condition.
To add an IAM policy binding for the role of 'roles/editor' for the user '[email protected]' on a project with identifier 'example-project-id-1', run:
gcloud projects add-iam-policy-binding example-project-id-1 --member='user:[email protected]' --role='roles/editor'
More information you can find at the documentation.
In addition, please have a look at the document Understanding policies.
A principal, also known as a member or identity, which can be a user account, service account, Google group, or domain.
So, the principal should exist, but you can use already existed accounts like Google Account or Google Workspace account.
Upvotes: 2