How to find, list, or search resources across services (APIs) and projects in Google Cloud Platform?

前端 未结 1 741
执笔经年
执笔经年 2020-12-10 22:53

In Google Cloud Platform (GCP), you can use list APIs or commands to list resources in a given project for a given type in a given service, like BigQuery datasets or compute

相关标签:
1条回答
  • 2020-12-10 23:27

    You can use search-all-resources to search all the resources across services (or APIs) and projects for a given organization, folder, or project.

    To search all the resources in a project with number 123:

    $ gcloud beta asset search-all-resources --scope=projects/123
    

    To limit to only compute resources:

    $ gcloud beta asset search-all-resources --scope=projects/123 --query="compute.googleapis.com"
    

    To limit to only resources containing "foo" as a sub string:

    $ gcloud beta asset search-all-resources --scope=projects/123 --query="*foo*"
    

    To list all the projects within an organization 456:

    $ gcloud beta asset search-all-resources --scope=organizations/456 --asset-types=cloudresourcemanager.googleapis.com/Project
    

    To find all the BigQuery datasets containing "foo" as a sub string within an organization 456:

    $ gcloud beta asset search-all-resources --scope=organizations/456 --query="bigquery datasets *foo*"
    

    You can set the scope to a project, a folder or an organization.

    To use the command, you must:

    • Enable Cloud Asset API, and

    • Have cloudasset.assets.searchAllResources permission upon the scope, which is included in these roles:

      • roles/cloudasset.viewer
      • roles/cloudasset.owner
      • roles/viewer
      • roles/editor
      • roles/owner

    Documentation:

    • Guide: https://cloud.google.com/asset-inventory/docs/searching-resources
    • API reference: https://cloud.google.com/asset-inventory/docs/reference/rest/v1p1beta1/resources/searchAll
    • Searchable resource types: https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types
    0 讨论(0)
提交回复
热议问题