要搜索编号为123的项目中的所有资源,请执行以下操作:$ gcloud beta asset search-all-resources --scope=projects/123要限制为仅计算资源:$ gcloud beta asset search-all-resources --scope=projects/123 --query="compute.googleapis.com"仅将包含"foo"的资源限制为作为子字符串:$ gcloud beta asset search-all-resources --scope=projects/123 --query="*foo*"要列出组织456中的所有项目,请执行以下操作:$ gcloud beta asset search-all-resources --scope=organizations/456 --asset-types=cloudresourcemanager.googleapis.com/Project要查找所有包含"foo"的BigQuery数据集,请执行以下操作:作为组织456中的子字符串:$ gcloud beta asset search-all-resources --scope=organizations/456 --query="bigquery datasets *foo*"您可以将范围设置为项目,文件夹或组织.要使用该命令,您必须: 启用 Cloud Asset API ,并 对作用域具有cloudasset.assets.searchAllResources权限,这些权限包括在这些角色中: roles/cloudasset.viewer roles/cloudasset.owner 角色/查看器角色/编辑器角色/所有者文档:指南: https://cloud.google.com/asset-inventory /docs/searching-resources API参考: https://cloud. google.com/asset-inventory/docs/reference/rest/v1p1beta1/resources/searchAll 可搜索的资源类型: https://cloud.google .com/asset-inventory/docs/supported-asset-types#searchable_asset_types 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 instances.But how to find or search resources across types, services, or even projects? 解决方案 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/123To 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/ProjectTo 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, andHave cloudasset.assets.searchAllResources permission upon the scope, which is included in these roles:roles/cloudasset.viewerroles/cloudasset.ownerroles/viewerroles/editorroles/ownerDocumentation:Guide: https://cloud.google.com/asset-inventory/docs/searching-resourcesAPI reference: https://cloud.google.com/asset-inventory/docs/reference/rest/v1p1beta1/resources/searchAllSearchable resource types: https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types 这篇关于如何在Google Cloud Platform中跨服务(API)和项目查找,列出或搜索资源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 08:41