Bird
Raised Fist0
GCPcloud~10 mins

Members (users, groups, service accounts) in GCP - Step-by-Step Execution

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Process Flow - Members (users, groups, service accounts)
Identify Member Type
User?
YesAssign User Role
No
Group?
YesAssign Group Role
No
Service Account?
YesAssign Service Account Role
No
Error: Invalid Member
End
This flow shows how a member is identified as a user, group, or service account, then assigned roles accordingly.
Execution Sample
GCP
members = ["user:alice@example.com", "group:devs@example.com", "serviceAccount:app@project.iam.gserviceaccount.com"]
for m in members:
    print(f"Assigning roles to {m}")
This code loops through a list of members and prints a message assigning roles based on member type.
Process Table
StepMemberMember Type IdentifiedActionOutput
1user:alice@example.comUserAssign User RoleAssigning roles to user:alice@example.com
2group:devs@example.comGroupAssign Group RoleAssigning roles to group:devs@example.com
3serviceAccount:app@project.iam.gserviceaccount.comService AccountAssign Service Account RoleAssigning roles to serviceAccount:app@project.iam.gserviceaccount.com
4end--All members processed
💡 All members processed, loop ends
Status Tracker
VariableStartAfter 1After 2After 3Final
mNoneuser:alice@example.comgroup:devs@example.comserviceAccount:app@project.iam.gserviceaccount.comNone
Key Moments - 2 Insights
How do we know if a member is a user, group, or service account?
We check the prefix before the colon in the member string (e.g., 'user:', 'group:', 'serviceAccount:') as shown in execution_table steps 1-3.
What happens if a member string does not match any known type?
The flow goes to an error or end state without assigning roles, as shown in the concept_flow where invalid members lead to 'Error: Invalid Member'.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the member type identified at step 2?
AUser
BService Account
CGroup
DInvalid
💡 Hint
Check the 'Member Type Identified' column at step 2 in the execution_table.
At which step does the member 'serviceAccount:app@project.iam.gserviceaccount.com' get processed?
AStep 2
BStep 3
CStep 1
DStep 4
💡 Hint
Look for the member name in the 'Member' column in execution_table.
If a new member 'user:bob@example.com' is added at the start, what will be the value of 'm' after the first iteration?
Auser:bob@example.com
Buser:alice@example.com
Cgroup:devs@example.com
DNone
💡 Hint
Refer to variable_tracker and understand how 'm' changes each iteration.
Concept Snapshot
Members in GCP IAM are identified by prefixes:
'user:' for users,
'group:' for groups,
'serviceAccount:' for service accounts.
Assign roles based on member type.
Invalid members cause errors or no assignment.
Full Transcript
This visual execution shows how GCP IAM members are processed. Each member string starts with a prefix that identifies its type: user, group, or service account. The code loops through each member, checks the prefix, and assigns roles accordingly. If a member does not match any known prefix, it is treated as invalid. Variables track the current member being processed. This helps beginners understand how member types are recognized and handled step-by-step.

Practice

(1/5)
1. Which of the following is a correct way to specify a user as a member in GCP IAM?
easy
A. user:alice@example.com
B. serviceaccount:alice@example.com
C. group:alice@example.com
D. member:alice@example.com

Solution

  1. Step 1: Understand member types in GCP IAM

    GCP IAM requires a prefix to identify the member type, such as user, group, or serviceaccount.
  2. Step 2: Identify the correct prefix for a user

    The prefix for an individual user is user:. So the correct format is user:email.
  3. Final Answer:

    user:alice@example.com -> Option A
  4. Quick Check:

    User members start with 'user:' [OK]
Hint: User members always start with 'user:' prefix [OK]
Common Mistakes:
  • Using 'member:' prefix which is invalid
  • Confusing group and user prefixes
  • Using serviceaccount prefix for users
2. Which of the following is the correct syntax to specify a service account member in GCP IAM?
easy
A. service-account:my-service@project.iam.gserviceaccount.com
B. serviceaccount:my-service@project.iam.gserviceaccount.com
C. group:my-service@project.iam.gserviceaccount.com
D. user:my-service@project.iam.gserviceaccount.com

Solution

  1. Step 1: Recall the prefix for service accounts

    Service accounts use the prefix serviceaccount: followed by the full service account email.
  2. Step 2: Check each option's prefix

    Only serviceaccount:my-service@project.iam.gserviceaccount.com uses the correct prefix serviceaccount: without hyphens or mistakes.
  3. Final Answer:

    serviceaccount:my-service@project.iam.gserviceaccount.com -> Option B
  4. Quick Check:

    Service accounts use 'serviceaccount:' prefix [OK]
Hint: Service accounts use 'serviceaccount:' prefix without hyphens [OK]
Common Mistakes:
  • Using 'service-account:' with a hyphen
  • Using 'user:' prefix for service accounts
  • Using incomplete email addresses
3. Given the following IAM policy binding snippet, which member will have access?
{"role": "roles/viewer", "members": ["group:dev-team@example.com", "user:bob@example.com"]}
medium
A. Only users in the dev-team group and Bob
B. Only Bob
C. Only the dev-team group
D. All users in the project

Solution

  1. Step 1: Analyze the members list in the policy

    The members list includes group:dev-team@example.com and user:bob@example.com. Both are granted the role.
  2. Step 2: Understand access granted by group and user members

    All users in the dev-team group plus the individual user Bob have the role permissions.
  3. Final Answer:

    Only users in the dev-team group and Bob -> Option A
  4. Quick Check:

    Group and user members both get access [OK]
Hint: Group members grant access to all group users [OK]
Common Mistakes:
  • Assuming only one member gets access
  • Confusing group with user access scope
  • Thinking all project users get access
4. You tried to add a member with user:alice to an IAM policy but got an error. What is the likely cause?
medium
A. IAM policy does not support user members
B. Using 'user:' prefix instead of 'group:'
C. Service account email used instead of user email
D. Missing full email address after 'user:' prefix

Solution

  1. Step 1: Check the required format for user members

    User members must include the full email address after the user: prefix.
  2. Step 2: Identify the error cause

    Using just user:alice is incomplete and causes a format error.
  3. Final Answer:

    Missing full email address after 'user:' prefix -> Option D
  4. Quick Check:

    User members need full email [OK]
Hint: Always include full email after 'user:' [OK]
Common Mistakes:
  • Using only username without domain
  • Confusing user and group prefixes
  • Assuming IAM rejects user members
5. You want to grant a Cloud Function access to a Pub/Sub topic using a service account. Which member string should you add to the Pub/Sub IAM policy?
hard
A. group:cloud-function-sa@project.iam.gserviceaccount.com
B. user:cloud-function-sa@project.iam.gserviceaccount.com
C. serviceaccount:cloud-function-sa@project.iam.gserviceaccount.com
D. service-account:cloud-function-sa@project.iam.gserviceaccount.com

Solution

  1. Step 1: Identify the correct member type for Cloud Function access

    Cloud Functions use service accounts to access other resources, so the member must be a service account.
  2. Step 2: Use the correct prefix for service accounts

    The prefix is serviceaccount: followed by the full service account email.
  3. Step 3: Verify the options

    Only serviceaccount:cloud-function-sa@project.iam.gserviceaccount.com uses the correct prefix and format.
  4. Final Answer:

    serviceaccount:cloud-function-sa@project.iam.gserviceaccount.com -> Option C
  5. Quick Check:

    Service accounts use 'serviceaccount:' prefix [OK]
Hint: Use 'serviceaccount:' prefix for Cloud Function identities [OK]
Common Mistakes:
  • Using 'user:' prefix for service accounts
  • Adding group instead of service account
  • Using incorrect prefix with hyphen