I need to generate inventory for all my GCP
resources. For this I can go through each of the components like VPC, Compute Engines, IAM
and generate the inventory manually. I am looking for some tool like gcloud
or using automation software like terraform/ansible
to generate the inventory. Any suggestions?
Yes, you can use Cloud Asset Inventory for this.
Here is a link to the quickstart guide.
My Cloud Shell was already properly configured so I only had to run:
gcloud beta asset search-all-resources
Enable the API if asked when running the above command.
As answered by @Erhard Czving, to list all assets use
`gcloud beta asset search-all-resources`
If we want to list all VPCs
, then
gcloud beta asset search-all-resources --asset-types compute.googleapis.com/Network
To list all SubNetworks
gcloud beta asset search-all-resources --asset-types compute.googleapis.com/Subnetwork
To list all ComputeInstances
gcloud beta asset search-all-resources --asset-types compute.googleapis.com/Instance
To export it to CloudStorage
gcloud beta asset export --project=<Project-ID> --output-path "gs://invent12/test"
List of all supported asset-ids
can be found here
https://cloud.google.com/asset-inventory/docs/supported-asset-types#searchable_asset_types
GCP has introduced the CLI to extract details of all resources in the project. 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.