【问题标题】:GCP: List grantable roles per resourceGCP:列出每个资源的可授予角色
【发布时间】:2019-10-17 23:00:56
【问题描述】:

我正在学习关于 GCP IAM 的 Qwicklabs 教程。

在某些时候,它提到了

使用 gcloud iam list-grantable-roles 命令返回一个列表 可应用于给定资源的所有角色。

但是,引用的示例通过遍历整个项目列出了可授予的角色:

gcloud iam list-grantable-roles //cloudresourcemanager.googleapis.com/projects/$DEVSHELL_PROJECT_ID

有没有办法运行上述命令,但只能在特定资源上运行,比如 StackdriverBigQuery

【问题讨论】:

    标签: google-cloud-platform google-cloud-iam


    【解决方案1】:

    有没有办法运行上述命令,但只能在特定的 资源,比如 Stackdriver 还是 BigQuery?

    是的。从以下示例中,您应该注意到一种命名模式。

    这个link是谷歌关于资源命名的文档。

    如果你想比项目更深入,那么你必须指定一个实际的资源。您不能只指定 BigQuery,您必须在 BigQuery 中指定数据集。对于 Stackdriver,您必须指定实际的日志名称。

    对于某些资源,gcloud 提供了命令行选项--uri。这将显示资源名称:

    gcloud compute instances list --uri
    

    注意:并非所有命令都支持命令行选项--uri。日志记录和 Biquery 都不支持 --uri

    计算引擎:

    gcloud iam list-grantable-roles //compute.googleapis.com/projects/[PROJECT_ID]/zones/[ZONE]/instances/[VM_NAME]
    

    BigQuery:

    gcloud iam list-grantable-roles //bigquery.googleapis.com/projects/[PROJECT_ID]/datasets/[DATASET_ID]
    

    Stackdriver 日志记录:

    gcloud iam list-grantable-roles //logging.googleapis.com/projects/[PROJECT_ID]/logs/cloudbuild
    

    【讨论】:

      猜你喜欢
      • 2022-01-22
      • 1970-01-01
      • 1970-01-01
      • 2019-05-21
      • 2016-06-13
      • 2019-05-16
      • 2021-04-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多