Search code examples
google-cloud-platformgcloud

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

  • 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)'”