[英]In GCP, how to list all the resources running under project?
I need to list out all the instance, container, function, notebooks, bucket, dataproc and composer running under project in all the region/locations.我需要列出在所有区域/位置的项目下运行的所有实例、容器、function、笔记本、存储桶、dataproc 和 composer。
Is it possible to list resources of all the regions location.是否可以列出所有区域位置的资源。 Gcloud or python script both can work for me
Gcloud 或 python 脚本都可以为我工作
My ultimate goal after listing is to put tag as per its name of the resource.列出后我的最终目标是根据资源名称放置标签。
Thanks谢谢
If you want to access through console, you could go to IAM & Admin Menu
, then select Asset Inventory
.如果你想通过控制台访问,你可以 go 到
IAM & Admin Menu
,然后 select Asset Inventory
。 Then you could see bunch of asset list.然后你可以看到一堆资产列表。
Click Resource
tab if you want download all the details in csv format.如果您想下载 csv 格式的所有详细信息,请单击“
Resource
”选项卡。
You can use Google Asset inventory feature and query your project like this您可以使用Google Asset 库存功能并像这样查询您的项目
gcloud asset search-all-resources --scope=projects/<PROJECT_ID> --page-size=500 --format=json
More detail in the documentation about the query format.有关查询格式的文档中的更多详细信息。
All the ressources aren't supported.不支持所有资源。 You can find the full list here (For example, Cloud Run isn't yet supported, but it's coming soon!)
您可以在此处找到完整列表(例如,尚不支持 Cloud Run,但即将推出!)
In search asset you will get abundance of irrelevant data.在搜索资产中,您将获得大量不相关的数据。 Better to use resource api of the resource you think relevant to you.
最好使用您认为与您相关的资源的资源 api。 Like
喜欢
compute.googleapis.com/Instance
storage.googleapis.com/Bucket
dataproc.googleapis.com/Cluster
container.googleapis.com/Cluster
cloudfunctions.googleapis.com/CloudFunction
dataflow.googleapis.com/Job //Notebook
gcloud asset search-all-resources --asset-types='compute.googleapis.com/Instance,storage.googleapis.com/Bucket' --query='labels.name:*' --format='table(name, assetType, labels)'”
GCP has introduced the CLI to extract details of all resources in the project. GCP 引入了 CLI 来提取项目中所有资源的详细信息。 You can further customize this to get details from all projects in the organization.
您可以进一步自定义它以获取组织中所有项目的详细信息。
https://cloud.google.com/sdk/gcloud/reference/asset/search-all-resources https://cloud.google.com/sdk/gcloud/reference/asset/search-all-resources
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.