Google Cloud IAM supports several member types that can be authorized to access Google Cloud resources. The following member types can be added to Google Cloud IAM to authorize access to your Google Cloud Platform services.
Google IAM Member Types:
- Google account – individual (me@example.com)
- Google group – (team@example.com)
- G Suite domain – (@example.com)
- Cloud Identity domain – same as G Suite domain without Google services
- Service account – JSON or P12 file for program access
Useful commands:
List current project: gcloud config list project
List all projects: gcloud projects list
List service accounts: gcloud iam service-accounts list
Listing IAM members is more difficult. Roles are assigned to projects. Members are assigned to roles. This command will list everything: gcloud projects get-iam-policy development-123456
.
For several gcloud commands such as add-iam-policy-binding
you must prefix the member identifier with the type such as: user:
, group:
, serviceAccount:
and domain:
.
For example: john@example.com
is specified as user:john@example.com
.
Google Account
A Google Account is a username and password that can log in to Google applications and Google services. Any email address that is associated with a Google account can be an identity.
The following gcloud command will add the user john@example.com to IAM and assign the role roles/iam.serviceAccountUser
After this command (takes about 60 seconds to take effect) the user can list and get details for the project’s service accounts. Change the project development-123456
to match your project.
1 2 3 |
gcloud projects add-iam-policy-binding development-123456 --member="user:john@example.com" --role="roles/iam.serviceAccountUser" |
This command will remove the role from the user.
1 2 3 |
gcloud projects remove-iam-policy-binding development-123456 --member="user:john@example.com" --role="roles/iam.serviceAccountUser" |
Note: You can replace “projects” in the previous commands with “organizations” for organization level commands and inheritance. I will discuss organizations in a future article.
Google Group
A Google Group is a G Suite Group that includes one or more Google Account members. These members are assigned the same privileges to access Google Cloud services.
The following gcloud command will add the G Suite group storage-admins@example.com
to IAM and assign the role roles/storage.admin
. Everyone in this group will have full control of buckets and objects.
1 2 3 |
gcloud projects add-iam-policy-binding development-123456 --member="group:storage-admins@example.com" --role="roles/storage.admin" |
Google G Suite Domain
A Google G Suite Domain represents all users in a G Suite domain name. They also call this Google Apps Domain.
1 2 3 |
gcloud projects add-iam-policy-binding development-123456 ^ --member="domain:example.com" ^ --role="roles/iam.serviceAccountUser" |
Google Cloud Identity Domain
Google Cloud Identity is the authentication system from Google G Suite. Cloud Identity manages users, devices, and apps without providing Google services.
Service Account
A Service Account is a special type of Google account that belongs to your application or virtual machine, instead of to an individual user. Service Account credentials are typically stored in Json files, but can also be accessed thru other methods such as thru Compute Engine metadata.
The following gcloud command will add the service account sa-storage-admin@example.com to IAM and assign the role roles/storage.admin
. This service account will have full control of buckets and objects.
1 2 3 |
gcloud projects add-iam-policy-binding development-123456 --member="serviceAccount:sa-storage-admin@example.com" --role="roles/storage.admin" |
Understanding Service Accounts
allUsers
The special identifier allUsers is an identifier that represents anyone who is on the internet, including authenticated and unauthenticated users. Note that some GCP APIs require authentication of any user accessing the service, and in those cases, allUsers will only imply authorization for all authenticated users.
Note: allUsers is a group, so this requires the group:
type identifier.
Warning: I do not recommend using this member type. There is no security.
1 2 3 |
gcloud projects add-iam-policy-binding development-123456 ^ --member="group:allUsers" ^ --role="roles/iam.serviceAccountUser" |
allAuthenticatedUsers
The special identifier allAuthenticatedUsers is a special identifier that represents anyone who is authenticated with a Google account or a service account. Users who are not authenticated, such as anonymous visitors, are not included.
Note: allAuthenticatedUsers is a group, so this requires the group:
type identifier.
Warning: I do not recommend using this member type. There is no security.
1 2 3 |
gcloud projects add-iam-policy-binding development-123456 ^ --member="group:allAuthenticatedUsers" ^ --role="roles/iam.serviceAccountUser" |
I design software for enterprise-class systems and data centers. My background is 30+ years in storage (SCSI, FC, iSCSI, disk arrays, imaging) virtualization. 20+ years in identity, security, and forensics.
For the past 14+ years, I have been working in the cloud (AWS, Azure, Google, Alibaba, IBM, Oracle) designing hybrid and multi-cloud software solutions. I am an MVP/GDE with several.
March 5, 2019 at 12:03 AM
Dear sir,
I want to know about allAuthenticatedUsers.
(Warning: I do not recommend using this member type. There is no security.
gcloud projects add-iam-policy-binding development-123456 ^
–member=”group:allAuthenticatedUsers” ^
–role=”roles/iam.serviceAccountUser” )
At this point, I don’t understand that there is no security about allAuthenticatedUsers.
Please explain me.
Best Regards,
Phyo Phyo Win
March 5, 2019 at 12:09 AM
The member type “allAuthenticatedUsers” means anyone with a Google account. Everyone can create a Google account.
Since anyone can create an account, this is the same as not having any security. When you consider that Google has over a billion Google Accounts users, this covers a lot of the planet.
This is why I say there is no security with “allAuthenticatedUsers”.