Prepare and test your skills

Prepare and test your skills

Principal identification in Google Cloud Identity and Access Management (IAM) (opens in a new tab) is the process of naming the exact identity that receives a role on a project or resource. A principal is any identity that can be granted access, and an IAM allow policy binds a role to that principal on a specific resource. Accurate identification ensures the intended person, group, or workload gets only the permissions it needs, because IAM enforces access based on that exact string.
A project uses four common identity categories for accurate association:
Google Accounts are individual human principals that represent one person in IAM. In the Google Cloud console, a Google Account is typically entered in the New principals field as an email address, such as my-user@example.com. In the gcloud command line, the same identity uses the form PRINCIPAL_TYPE:ID, such as user:my-user@example.com.
For the principal type user, the domain name in the identifier must be a Google Workspace domain or a Cloud Identity domain. A Google Account is also the typical identifier for the human who will use another identity. When creating a service account, the Service account users role field asks for the identifier of the principal that will attach the service account to other resources, such as Compute Engine instances. That separation keeps two questions distinct: what the service account itself can access, and who is allowed to attach and use it.
Google Groups are group principals that let one role binding cover many users at once. Granting a role to a group gives the same access to every current member without creating a separate binding for each person. Using Google Groups is more efficient than individual authorizations when teams are large, such as adding 50 users to an Administrator group, 75 users to an Editor group, and 100 users to a Reader group without writing 225 separate rules.
Group-based access works best when groups are nested by purpose and share a domain. An organization can maintain a parent group such as gke-security-groups@YOUR-DOMAIN in Google Workspace and add the access-control groups as nested members of that parent, rather than adding individual users directly to the parent. User accounts used with this feature should use the same domain name as their group, which keeps membership lookup consistent and avoids domain-mismatch errors.
Service accounts are non-human principals used by applications, virtual machines, and automation to authenticate to Google Cloud. A service account is identified by its email address in the form SERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com. The Role field selected during creation controls which resources that service account can access in the project, and those roles can be revoked or expanded later.
A service account becomes useful only after it is attached to a resource that runs code. A Compute Engine instance, for example, is created with a --service-account flag set to the service account email, so traffic and API calls from that instance authenticate as the service account. The human or group allowed to perform that attachment must first be granted the Service Account User role on the service account, such as with gcloud iam service-accounts add-iam-policy-binding using --member="user:USER_EMAIL". Service agents are Google-provided service accounts managed by Google, and their email addresses appear in the console only after selecting the Include Google-provided role grants checkbox.
Google Workspace domains define the organizational identity boundary that makes user identifiers valid in IAM. A Workspace domain or Cloud Identity domain owns the user names, so a user: principal is accepted only when its domain belongs to one of those identity systems. This rule ensures that project access is tied to an organization-managed identity rather than an unverified email string.
Workforce identity pools extend the same principal model to external users and groups without creating Google Accounts for them. An individual external user is identified as principal://iam.googleapis.com/locations/global/workforcePools/WORKFORCE_POOL_ID/subject/SUBJECT_VALUE, where the subject value can be an email such as alex@cymbalgroup.com. An external group is identified as principalSet://iam.googleapis.com/locations/global/workforcePools/WORKFORCE_POOL_ID/group/GROUP_ID, so one IAM binding can authorize the whole federated group.
Principal identifiers are the exact values IAM stores in a role binding to record who receives access. In the console, a new binding is entered as a plain identifier such as my-user@example.com or //iam.googleapis.com/locations/global/workforcePools/example-pool/group/example-group@example.com. In gcloud, the same binding uses an explicit type prefix such as user:my-user@example.com or principalSet://iam.googleapis.com/locations/global/workforcePools/example-pool/group/example-group@example.com.
Granting a project role in the console follows an ordered workflow:
A left-to-right process flow showing the five steps to grant a project IAM role: select project, start Grant Access, enter principal, select least-privilege role, and Save to update the allow policy.
Inherited roles cannot be edited from a child resource. To change an inherited grant, go to the resource where the role was originally granted and edit it there.
Exam tip: For the user: principal type, the email domain must be a Google Workspace domain or a Cloud Identity domain, or the binding will not represent a valid managed identity.
Role differentiation and the principle of least privilege in a Google Cloud project control what a member can do by giving them only the permissions they need. Identity and Access Management (IAM) (opens in a new tab) enforces this through a binding that connects a principal, a role, and a resource. A principal is a user, group, service account, or service agent, a role is a collection of permissions, and the project is the resource where the binding applies. When a principal is granted a role on a project, that principal receives every permission contained in the role for that project and for resources that inherit from it.
The principle of least privilege means a member possesses only the minimum permissions required for a specific task and nothing more. A project enforces this principle when an administrator selects a role that includes only the permissions the principal needs. The Google Cloud console supports this choice with a role drop-down list and an optional condition, while the gcloud command supports it with --role and --condition flags. Because broad roles increase the risk of accidental change or misuse, least privilege favors narrow, task-specific roles over wide administrative access.
Primitive roles, also called basic roles in Google Cloud, are broad project-level roles that include many permissions across many services. The three primitive roles are Owner (roles/owner), Editor (roles/editor), and Viewer, and they apply to all resources in a project rather than to one service. Owner can manage the project, its resources, and its access policies, Editor can create and change most resources but cannot manage access, and Viewer can only view resources. Because primitive roles grant far more access than most tasks require, they do not follow least privilege and should not be used in production environments.
Predefined roles are Google-maintained roles that bundle permissions for a specific service or job function. A predefined role uses the name format roles/SERVICE.IDENTIFIER, such as roles/resourcemanager.projectCreator for creating projects or roles/serviceusage.serviceUsageAdmin for enabling APIs. The predefined role flows from Google to the project when an administrator grants it to a principal, and the principal can then perform only the tasks in that bundle. Predefined roles support least privilege better than primitive roles because an administrator can choose a role that matches the task, such as Developer Connect Admin or Service Account Token Creator, instead of granting full project ownership.
Custom roles are administrator-defined roles that bundle a specific set of permissions chosen by the organization. A custom role is created when no predefined role matches the task, either because a predefined role is too broad or because it lacks a needed permission. A project-level custom role uses the format projects/PROJECT_ID/roles/IDENTIFIER, while an organization-level custom role uses the format organizations/ORG_ID/roles/IDENTIFIER. Because the organization controls the permission list, custom roles can enforce least privilege most closely, but they also require the organization to maintain the permission bundle over time.
Choosing a role for a project member means comparing how broad the role is, who maintains it, and how well it matches the task. A role granted at the project level flows down to resources in that project, and inherited roles cannot be edited at the lower resource and must be changed where they were granted. Access is granted in the console through IAM and Grant access, where the administrator enters the principal identifier, selects a role, and clicks Save, or through gcloud ... add-iam-policy-binding with --member and --role. The response is an updated IAM allow policy that lists the new binding of principal to role.
| Role type | Who defines permissions | Scope of access |
|---|---|---|
| Primitive, such as Owner and Editor | Very broad access across all services in a project | |
Predefined, such as roles/SERVICE.IDENTIFIER | Narrow access for a specific service or job function | |
Custom, such as projects/PROJECT_ID/roles/IDENTIFIER | Customer organization | Exact set of permissions chosen for a specific task |
Exam tip: In production, do not grant Owner, Editor, or Viewer; grant a predefined role or custom role that meets the need.
Implementation and management via console and CLI is the practice of granting Identity and Access Management (IAM) roles by editing the allow policy attached to a resource. An allow policy (opens in a new tab) lists which principals can access the resource and what actions they can perform, and IAM checks that policy to decide whether a principal is authorized. Both the Google Cloud console and the gcloud CLI update the same allow policy, so consistent use of either tool keeps resource security predictable.
IAM authorization controls who can do what on which Google Cloud resource through permissions bundled into roles. A principal is an authenticated identity such as a user, group, service account, or domain, and a role is a bundle of permissions that lets that principal perform tasks. To grant access, an administrator updates the allow policy on the resource with the principal and the role to grant.
A typical request flow moves from the user to the administrator to the resource in order:
Roles granted on container resources apply broadly, while roles granted on service-specific resources apply narrowly:
| Grant location | Scope | Effect |
|---|---|---|
| Projects, folders, and organizations | Container resources in the resource hierarchy | Access applies to the container and all service-specific resources it contains |
| Service-specific resources | Single service feature, such as an instance, disk, or image | Access is limited to only that resource for more granular control |
The Google Cloud console grants IAM roles through the IAM page for a selected project, folder, or organization. Granting at the project, folder, or organization level controls access to that container and all resources within it. The console workflow depends on whether the principal already has roles on the selected resource.
First select the resource, then add the principal and role in order:
my-user@example.com. For an existing principal, find its row and click Edit principal, then Add another role.The console shows inherited roles but does not allow editing them in place. To change an inherited role, go to the resource where the role was granted. To see a service agent, select the Include Google-provided role grants checkbox to reveal its email address.
The gcloud CLI grants and revokes IAM roles with add-iam-policy-binding and remove-iam-policy-binding commands that target a specific project, organization, or service resource. The command sends the principal, role, and resource name to IAM, which updates the allow policy on that resource. This makes the CLI useful for repeatable grants to users and service accounts.
The grant pattern names the resource group, the resource, the member, and the role:
gcloud projects add-iam-policy-binding my-project \
--member=user:my-user@example.com --role=roles/cloudbuild.builds.viewer
In this pattern, the group is the resource type such as projects or organizations, the resource is the project or organization name, the member identifies the principal, and the role is the role ID. To revoke the same access, the revocation flows from the same resource back to IAM with the remove command and the same member and role values. Common member formats include user:user@gmail.com, group:admins@googlegroups.com, serviceAccount:server@example.gserviceaccount.com, domain:example.com, and workforce identities such as principal://iam.googleapis.com/locations/global/workforcePools/....
Exam tip: To grant the Owner role (roles/owner) on a project to a user outside your organization, use the Google Cloud console, not the gcloud CLI.
Auditing IAM assignments means reviewing the IAM table to confirm that each principal has only the roles it needs on the correct resource. The IAM page lists each binding in Principal and Role columns, so an auditor can trace which user, group, or service account holds which role. Because container grants inherit downward, a project-level grant automatically affects all resources in that project unless a more granular service-specific binding is used instead.
Consistent policy application depends on choosing the narrowest scope and the smallest role that still allows the work. Administrators follow least privilege by selecting roles with only required permissions, adding conditions when access should be temporary or attribute-based, and using advanced controls such as deny policies, principal access boundary policies, and Privileged Access Manager when allow policies alone are not enough. Other services can also affect effective access even when IAM allows it, including Access Context Manager, Identity-Aware Proxy (IAP), Organization Policy Service, and VPC Service Controls.
user: principal type, the email domain must be a Google Workspace domain or a Cloud Identity domain.projects/PROJECT_ID/roles/IDENTIFIER to bundle an organization-chosen set of permissions.Primitive, predefined, and custom roles in Google Cloud Identity and Access Management differ in who defines the permissions and how broad access is. Primitive roles such as Owner, Editor, and Viewer are defined by Google and grant very broad access across all services in a project, so they should not be used in production. Predefined roles are defined by Google for a specific service or job function, while custom roles are defined by the customer organization with formats such as projects/PROJECT_ID/roles/IDENTIFIER to bundle the exact permissions chosen for a task.
Use a Google Group when one role binding should cover many users at once because granting a role to the group gives the same access to every current member without creating a separate binding for each person. This approach is more efficient than individual authorizations for large teams, such as adding 50 users to an Administrator group, 75 users to an Editor group, and 100 users to a Reader group without writing 225 separate rules.
A new principal is granted a role by opening the Identity and Access Management page with the correct project selected, clicking Grant access, and entering the principal identifier exactly. Select a role that includes only the permissions the principal needs with an optional condition if required, then click Save to update the allow policy and grant the role on the resource.
An inherited role cannot be edited from a child resource because access applies where the binding was created. To change an inherited grant, go to the resource where the role was originally granted and edit it there.
A company is onboarding a new database administrator who is responsible for managing Cloud SQL database instances within a Google Cloud project. Company security policies enforce the principle of least privilege, requiring that the administrator have full administrative control over Cloud SQL resources while preventing modification of unrelated services such as Compute Engine instances and Cloud Storage buckets.
Which approach should you take to grant the required permissions while minimizing administrative maintenance overhead?
Assign the primitive Editor role (roles/editor) at the project level to the database administrator
Create and assign a custom IAM role containing manually selected Cloud SQL permissions
Assign a predefined role such as Cloud SQL Admin (roles/cloudsql.admin) to the database administrator
Grant individual database IAM permissions directly to the user account at the project level
Last updated