Prepare and test your skills

Prepare and test your skills

A custom role (opens in a new tab) in Identity and Access Management (IAM) is a user-defined collection of permissions that grants exactly the access a job needs and nothing more. Unlike basic roles that grant broad access and predefined roles that are managed by Google Cloud, a custom role lets an administrator pick a specific permission list to support least privilege. When the custom role is granted to a principal such as a user, group, or service account, the principal receives all permissions in that role for the resource where the grant is made.
Components of a custom role definition are the fields that identify the role, describe its purpose, and control its behavior. The title is the human-readable name shown in the Google Cloud console, while the name is the full identifier used in allow policies (opens in a new tab), such as projects/PROJECT_ID/roles/IDENTIFIER for a project-level role and organizations/ORG_ID/roles/IDENTIFIER for an organization-level role. The ID is the unique part after roles/ in the name, and the ID cannot be changed after the role is created.
roles/ in the name, which is immutable after creation.SERVICE.RESOURCE.VERB format, such as compute.instances.list and compute.instances.stop.Selecting permissions for least privilege means building a custom role only from permissions that are supported in custom roles and valid at the role scope. An organization-level custom role can include any supported permission, while a project-level custom role can include any supported permission except permissions that only work at the organization or folder level, such as resourcemanager.organizations.get. A custom role is bound to the scope where it is created, so access with that role can only be granted within the same organization or project.
Administrators validate available permissions with gcloud iam list-testable-permissions for a full resource name, filtered to exclude customRolesSupportLevel=NOT_SUPPORTED. Some permissions may not appear or work in a custom role if the API for that service is not enabled. Each custom role can contain up to 3,000 permissions, and the combined size of the title, description, and permission names cannot exceed 64 KB.
Creating a custom role in its scope requires role-management access on the organization or project where the role will live. To manage project roles, an administrator needs the Role Administrator role (roles/iam.roleAdmin) on that project, and to manage organization roles, an administrator needs the Organization Role Administrator role (roles/iam.organizationRoleAdmin) on that organization. If a larger permission set is needed than the limits allow, the permissions can be split across related roles with clear titles such as Custom Admin (1 of 2) and Custom Admin (2 of 2).
To create a custom role from scratch in the Google Cloud console:
A custom role can also be based on an existing predefined role by selecting that role as a starting point. When a predefined role contains deprecated permissions or permissions not permitted in custom roles, the new custom role omits those permissions automatically.
Exam tip: Custom roles cannot be defined at the folder level — to use a custom role within a folder, define the custom role at the organization level.
Updating and maintaining a custom role means editing its permissions and description, tracking its readiness with launch stages, and disabling or deleting it when it is no longer safe to use. The ETag for a custom role changes each time the role is modified, while basic and predefined roles always use the ETag AA==. Because the ETag identifies the current version of the role definition, concurrent edits can be detected before one update overwrites another.
Most launch stages are informational and show whether a custom role is in ALPHA, BETA, or GA and ready for widespread use. The DISABLED stage stops the role from taking effect, which is useful when a role violates security requirements or needs review before principals can use it again. Ongoing validation means reviewing the included permissions against least-privilege needs, checking role definitions with the console, gcloud iam roles describe, or projects.roles.get and organizations.roles.get, and removing permissions that grant more access than the task requires.
Identity and Access Management (IAM) (opens in a new tab) roles are collections of permissions that control what actions a principal can perform on Google Cloud resources. A principal can be a user, a group, or a service account, and permissions are never assigned directly to the principal. An administrator grants one or more roles to the principal by updating the allow policy attached to a resource, and the principal then receives all permissions contained in those roles.
What an IAM role contains is a fixed set of fields that identify the role and define what it allows. The title is the human-readable name shown in the Google Cloud console, while the name is the identifier used in allow policies. Permissions use the format SERVICE.RESOURCE.VERB, such as compute.instances.list to list Compute Engine instances or compute.instances.stop to stop a virtual machine, and each permission usually maps to one REST API method.
roles/SERVICE.IDENTIFIER for predefined roles, projects/PROJECT_ID/roles/IDENTIFIER for project-level custom roles, and organizations/ORG_ID/roles/IDENTIFIER for organization-level custom roles.roles/ for custom roles.AA== for basic and predefined roles and changes with each update for custom roles.Basic roles are broad-access roles that grant wide permissions across Google Cloud resources rather than permissions for one specific service. A principal with a basic role can act on many different resource types within the scope where the role is granted, which makes basic roles simple to assign but difficult to limit. Because basic roles include such a wide set of permissions, they grant more access than most jobs need and do not follow the principle of least privilege.
Predefined roles are granular, service-specific roles that are created and managed by Google Cloud for common use cases and access patterns. Each predefined role bundles only the permissions needed for a particular job on a particular service, such as roles/compute.networkAdmin for managing networks or roles/bigquery.dataViewer for viewing BigQuery data. When Google Cloud adds new capabilities to a service, Google Cloud can add new permissions to its predefined roles and can add new predefined roles at any time.
Custom roles (opens in a new tab) are granular roles that you define by choosing your own list of permissions to support least-privilege access. A custom role is created at either the organization level or the project level, and the permissions available for the role depend on that level because some permissions can only be used at the organization level. Access to a custom role can only be granted within the same organization or project where the custom role was created, so an organization-level role cannot be granted on a separate organization.
Custom roles are useful when predefined roles are too broad, too narrow, or subject to change. If an organization requires role definitions to remain unchanged over time, a custom role preserves that stability because Google Cloud does not automatically add new permissions to it. Creating a custom role lets you combine permissions from existing predefined roles into one tailored set for sensitive tasks or separation of duties.
How role grants connect principals to resources is through the allow policy attached to a resource, which links a principal, a role, and that resource. The administrator adds the principal and the role to the allow policy, IAM checks that policy when the principal calls an API, and the call succeeds only when the policy provides the required permission. Where the role is granted controls how far the access reaches, because roles granted on container resources such as organizations, folders, and projects apply to all service-specific resources they contain.
Performing a new action without permission generally follows an ordered workflow:
When a principal has multiple roles, the effective permissions are the union of all permissions in those roles.
| Role type | Who defines permissions | Scope of access |
|---|---|---|
| Basic roles | Google Cloud | Broad access across many Google Cloud resources |
| Predefined roles | Google Cloud | Granular access for a specific service and common use case |
| Custom roles | You, from a user-specified permission list | Tailored access limited to the organization or project where created |
Exam tip: Predefined roles are managed by Google Cloud and can gain new permissions over time, while custom roles contain only the permissions you select and do not change automatically.
Identity and Access Management (IAM) (opens in a new tab) in Google Cloud controls who can do what by bundling permissions into roles and granting those roles to principals. A principal is an authenticated identity such as a user, group, or service account. A role contains a set of permissions, and when a principal is granted that role on a resource, the principal receives all of the permissions in the role for that resource.
How permissions aggregate within roles is by addition, where a role grants its full permission set together and multiple roles combine into a larger set. Each permission has the format SERVICE.RESOURCE.VERB, such as compute.instances.list to list Compute Engine instances or pubsub.topics.publish to publish to a Pub/Sub topic. Each permission usually matches one REST API method, so calling that method requires that permission.
When an administrator grants a role, IAM records the grant in the allow policy attached to the resource. The allow policy lists which principals have access and which roles they hold, and IAM checks that policy when a principal calls an API. If a principal holds more than one role, the effective permissions are the union of each role's permissions. Permissions only add together, so granting an extra role never removes access granted by another role.
A principal without the required permission cannot perform the action until an administrator grants a role that includes it. The normal workflow moves through an ordered sequence:
Comparing role types for different workloads shows how breadth, management, and stability affect the choice between basic, predefined, and custom roles. Basic roles provide broad access across Google Cloud resources. Predefined roles provide granular access for a specific service and are managed by Google Cloud. Custom roles (opens in a new tab) provide granular access according to a user-specified list of permissions.
| Role type | Breadth of access | Managed by | Choose when |
|---|---|---|---|
| Basic roles | Broad, across many services | Google Cloud | Almost never for workloads, because access is too wide for least privilege |
| Predefined roles | Narrow, focused on a service or job function | Google Cloud | A predefined role matches the task, such as network administration or data viewing |
| Custom roles | Exact, only the listed permissions | Customer | No predefined role matches, or the role definition must stay unchanged over time |
Predefined roles can change when Google Cloud adds new capabilities, including new permissions or new roles. Custom roles do not automatically gain new permissions, which makes custom roles useful when an organization needs a stable definition. Custom roles are created at the organization or project level, and only permissions that are valid at that level can be included.
Where role grants apply in the resource hierarchy sets the permission boundary for what the principal can reach. The hierarchy flows from organization to folder to project to service-specific resources such as instances, disks, buckets, datasets, and tables. A role granted on a parent container, such as an organization, folder, or project, is inherited by all of that parent's children.
A hierarchy from organization to folder to project to service resources showing that an IAM role granted on a parent is inherited by all descendant resources.
Granting on a container resource is convenient but broad. Granting a BigQuery role on a project, for example, grants permissions on all BigQuery resources in that project. Granting the same role on one dataset or table limits access to only that dataset or table. Overly broad access increases risk because a compromised account or mistaken change can affect many resources, while overly restrictive access breaks legitimate work because API calls fail without the required permission.
Exam tip: A role granted on an organization, folder, or project applies to all descendant resources, so choose the lowest resource level that still lets the workload succeed.
Choosing roles that support least privilege means giving each principal only the minimum permissions needed for its workload and no more. Least privilege states that no principal should have more permissions than it actually needs. Start with predefined roles at the most specific resource level, add a second role only when the task needs permissions from two areas, and remember that the result will be the union of both roles.
Before granting, verify that the candidate role actually contains the required permission. A permission can be checked by viewing the role in the Google Cloud console, running the gcloud iam roles describe command, calling the IAM API roles.get() method for predefined roles, or searching the permissions reference and predefined role descriptions. Use separation of duties for sensitive work by splitting administration, networking, billing, and security duties across different groups with different roles. Choose a custom role only when predefined roles are too broad or too narrow and the exact permission set must be controlled and kept stable.
Basic roles provide broad access across many Google Cloud resources, predefined roles provide granular service-specific access managed by Google Cloud, and custom roles provide tailored access defined by the customer from a user-specified permission list. When a principal holds multiple roles, the effective permissions are the union of all permissions in those roles, so granting an extra role never removes access.
Use a custom role when no predefined role matches the task, when predefined roles are too broad or too narrow, or when the role definition must stay unchanged over time. Predefined roles are managed by Google Cloud and can gain new permissions over time, while custom roles contain only the permissions you select and do not change automatically.
Custom roles can be created only at the organization level or the project level and cannot be defined at the folder level, and access with that role can only be granted within the same organization or project where it was created. An organization-level custom role can include any supported permission, while a project-level custom role cannot include permissions that only work at the organization or folder level, such as resourcemanager.organizations.get.
Your team manages several project-level custom IAM roles using configuration files and the gcloud CLI. Multiple cloud administrators have permission to modify these roles. You need to add additional permissions to an existing custom role named customAppViewer in the project corp-app-prod. You must ensure that any concurrent updates made by other team members are not accidentally overwritten.
What should you do?
Run gcloud iam roles delete customAppViewer --project=corp-app-prod, update your local YAML file with the new permissions, and immediately recreate the role using gcloud iam roles create customAppViewer --project=corp-app-prod --file=role-definition.yaml.
Define the updated role at the parent folder level using gcloud iam roles create customAppViewer --folder=FOLDER_ID, so that IAM automatically merges and versions conflicting role updates across child projects.
Run gcloud iam roles describe customAppViewer --project=corp-app-prod to get the current role definition and its etag, update the YAML file with the new permissions and the retrieved etag, and run gcloud iam roles update customAppViewer --project=corp-app-prod --file=role-definition.yaml.
Update your local YAML file with the new permissions using wildcard notation such as storage.objects.*, and run gcloud iam roles update customAppViewer --project=corp-app-prod --file=role-definition.yaml --force to override concurrency checks.
Last updated