Zama Ques
Zama Ques

Reputation: 1534

Generating inventory of GCP resources

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 ?

Upvotes: 0

Views: 1238

Answers (3)

Utkarsh Sharma
Utkarsh Sharma

Reputation: 625

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

Upvotes: 0

phteven
phteven

Reputation: 453

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.

Upvotes: 3

Zama Ques
Zama Ques

Reputation: 1534

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

Upvotes: 2

Related Questions