如何在 GCP 中列出包含给定权限的所有 IAM 角色

How to list all the IAM roles that include a given permission in GCP

在发现用户(主体)需要额外权限才能执行任务后,我想知道哪些标准角色包含该权限,以便我可以将角色添加到用户。我还想知道每个角色提供哪些其他权限,以便我可以 select 具有符合用户需求的权限的角色。我无法使用自定义角色,我正在避免使用基本角色,因为它们太宽泛了。

目前我正在使用https://cloud.google.com/iam/docs/understanding-roles#support-roles。 我搜索权限,然后向上滚动以查看角色名称和该角色中的所有其他权限。

它可以工作,但对于必须是常见任务的任务来说速度很慢。

是否有更好的网页或 gcloud api 命令可以更好地工作。

GCP 文档提供了 a (huge) page,可让您识别授予它们的不同角色。

除了您引用的页面之外,您稍后还可以使用 gcloud CLI,describe a role 并查看它授予的不同权限。例如:

gcloud iam roles describe roles/iam.roleViewer

该命令将输出:

description: Read access to all custom roles in the project.
etag: AA==
includedPermissions:
- iam.roles.get
- iam.roles.list
- resourcemanager.projects.get
- resourcemanager.projects.getIamPolicy
name: roles/iam.roleViewer
stage: GA
title: Role Viewer

AFAIK,gcloud CLI 不会让您有机会获得授予它的角色。