A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/iam/docs/viewing-grantable-roles below:

Viewing the grantable roles on resources | IAM Documentation

Skip to main content Viewing the grantable roles on resources

Stay organized with collections Save and categorize content based on your preferences.

Before you grant an Identity and Access Management (IAM) role to a user for a resource, you might want to know what roles are available to grant on a particular resource.

Before you begin Required roles

To get the permissions that you need to list grantable roles, ask your administrator to grant you the Security Reviewer (roles/iam.securityReviewer) IAM role on the resource that you want to list grantable roles for. For more information about granting roles, see Manage access to projects, folders, and organizations.

This role contains the

getIamPolicy

permissions for all resource types. To list grantable roles, you need the

getIamPolicy

permission for the resource that you want to list grantable roles for—for example, to list grantable roles for a project, you need the

resourcemanager.projects.getIamPolicy

permission.

You might also be able to get these permissions with custom roles or other predefined roles.

Understanding what roles are grantable

A role is grantable on or above a resource if it contains any permissions for that resource type. For example, the storage.admin role grants permissions to the storage.buckets.get and storage.objects.get APIs, so it is grantable on the Storage Buckets and Storage Objects resource types.

Roles can also be granted "above" the resource types that their permissions are defined for. In other words, roles for lower-level resources can be granted on a resource that is higher in the Google Cloud resource hierarchy. For example, the storage.admin role can also be granted at the project or organization levels, in addition to Storage Buckets.

Permissions granted by a role only affect resources at the specified level or below; they do not affect higher-level or peer resources. Additionally, when a role is granted on a resource, only permissions applicable to the given resource are granted, regardless of the role's name, description, or other permissions it contains. For example, assigning the role resourcemanager.organizationAdmin (which grants the permission resourcemanager.projects.list) to a user on the project level only grants them permissions for that specific project. It will not allow them to list or administer all projects in the organization. Similarly, assigning the compute.admin role on a specific Compute Engine instance only grants permissions for that instance, not others in the project.

Listing grantable roles

You can list grantable roles using the Google Cloud console, the Google Cloud CLI, the IAM API, or the IAM client libraries.

The Google Cloud console always lists all grantable roles for the resource you're viewing. The Google Cloud CLI, IAM API, and client libraries only list grantable roles for enabled APIs.

Console

To view grantable roles for a project, folder, or organization, do the following:

  1. In the Google Cloud console, go to the IAM page.

    Go to the IAM page

  2. Click Select a project at the top of the page.

  3. Select the project, folder, or organization for which you want to view grantable roles.

  4. Click person_add Grant access.

  5. Click Select a role. This menu displays all the roles, including any custom roles, that you can grant on this resource.

To view grantable roles for other resource types, do the following:

  1. In the Google Cloud console, go to the page listing the resource for which you want to view grantable roles.

    For example, to manage access to a Compute Engine instance, go to the VM instances page.

    Go to VM instances

  2. Select the checkbox next to the resource for which you want to view grantable roles.

  3. Ensure that the info panel is visible. If it is not visible, click Show info panel.

  4. Click person_add Add principal.

  5. Click Select a role. This menu displays all the roles, including any custom roles, that you can grant on this resource.

gcloud

Use the gcloud iam list-grantable-roles command to return a list of all roles that can be applied to a given resource.

gcloud iam list-grantable-roles full-resource-name

Depending on the desired resource, a large number of roles may be returned. To limit the results, you can specify a filter expression.

The output will look something like:

description: Full control of all Compute Engine resources.
name: roles/compute.admin
title: Compute Admin
---
description: Full control of Compute Engine instance resources.
name: roles/compute.instanceAdmin
title: Compute Instance Admin

# Additional results here...
C++

To learn how to install and use the client library for IAM, see IAM client libraries. For more information, see the IAM C++ API reference documentation.

To authenticate to IAM, set up Application Default Credentials. For more information, see Before you begin.

C#

To learn how to install and use the client library for IAM, see IAM client libraries. For more information, see the IAM C# API reference documentation.

To authenticate to IAM, set up Application Default Credentials. For more information, see Before you begin.

Go

To learn how to install and use the client library for IAM, see IAM client libraries. For more information, see the IAM Go API reference documentation.

To authenticate to IAM, set up Application Default Credentials. For more information, see Before you begin.

Java

To learn how to install and use the client library for IAM, see IAM client libraries. For more information, see the IAM Java API reference documentation.

To authenticate to IAM, set up Application Default Credentials. For more information, see Before you begin.

Python

To learn how to install and use the client library for IAM, see IAM client libraries. For more information, see the IAM Python API reference documentation.

To authenticate to IAM, set up Application Default Credentials. For more information, see Before you begin.

REST

The roles.queryGrantableRoles method returns a list of all roles grantable on a resource.

Before using any of the request data, make the following replacements:

HTTP method and URL:

POST https://iam.googleapis.com/v1/roles:queryGrantableRoles

Request JSON body:

{
  "fullResourceName": "FULL_RESOURCE_NAME"
}

To send your request, expand one of these options:

curl (Linux, macOS, or Cloud Shell) Note: The following command assumes that you have logged in to the gcloud CLI with your user account by running gcloud init or gcloud auth login , or by using Cloud Shell, which automatically logs you into the gcloud CLI . You can check the currently active account by running gcloud auth list.

Save the request body in a file named request.json, and execute the following command:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://iam.googleapis.com/v1/roles:queryGrantableRoles"
PowerShell (Windows) Note: The following command assumes that you have logged in to the gcloud CLI with your user account by running gcloud init or gcloud auth login . You can check the currently active account by running gcloud auth list.

Save the request body in a file named request.json, and execute the following command:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `


-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://iam.googleapis.com/v1/roles:queryGrantableRoles" | Select-Object -Expand Content
APIs Explorer (browser)

Copy the request body and open the method reference page. The APIs Explorer panel opens on the right side of the page. You can interact with this tool to send requests. Paste the request body in this tool, complete any other required fields, and click Execute.

You should receive a JSON response similar to the following:

{
  "roles": [
    {
      "name": "roles/compute.admin",
      "title": "Compute Admin",
      "description": "Full control of all Compute Engine resources."
    },
    {
      "name": "roles/compute.instanceAdmin",
      "title": "Compute Instance Admin (beta)",
      "description": "Full control of Compute Engine instance resources."
    }
  ]
}

In the examples above, the full resource name is a scheme-less URI consisting of a DNS-compatible API service name and a resource path.

For example, to return all roles grantable on a project, use:

//cloudresourcemanager.googleapis.com/projects/project-id

Lower-level resources have a more detailed fully qualified name. For example, use the following to return all roles grantable on a Compute Engine instance:

//compute.googleapis.com/projects/project-id/zones/zone-name/instances/instance-id
What's next

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-02 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-07-02 UTC."],[[["This page provides guidance on how to determine which Identity and Access Management (IAM) roles can be granted to a user for a specific resource within Google Cloud."],["Before listing grantable roles, you must enable the IAM API and set up authentication, which varies depending on whether you are using the console, gcloud CLI, or client libraries."],["To list grantable roles, you must have the `Security Reviewer` role, which contains the `getIamPolicy` permission, or a custom role that has the equivalent permissions."],["Roles are grantable on or above a resource if they contain any permissions for that resource type and can be granted at higher levels of the resource hierarchy, although permissions only affect resources at the specified level or below."],["Grantable roles can be listed through the Google Cloud console, the gcloud CLI, the IAM API, or the IAM client libraries, with the console listing all grantable roles and the other methods only listing roles for enabled APIs."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4