'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.

Is it possible to list resources of all the regions location. Gcloud or python script both can work for me

My ultimate goal after listing is to put tag as per its name of the resource.

Thanks



Solution 1:[1]

In search asset you will get abundance of irrelevant data. Better to use resource api of the resource you think relevant to you. 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)'”

Solution 2:[2]

You can use Google Asset inventory feature and query your project like this

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!)

Solution 3:[3]

If you want to access through console, you could go to IAM & Admin Menu, then select Asset Inventory. Then you could see bunch of asset list.

GCP Console

Click Resource tab if you want download all the details in csv format.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Anshuman
Solution 2 guillaume blaquiere
Solution 3 Yugo Gautomo