Finding resources in GCP using gCloud

To quickly find all resources within a project or even a parent org, we can use asset manager and resource manager API in GCP.

Passing in a Project name

gcloud asset search-all-resources --scope=projects/my-proj-name --page-size=500 --format=json

Passing in a Resource Type
To look for individual resource types (all VMs in an org), use the following APIs, instead of passing in the project name, pass in the type of resource (API)
compute.googleapis.com/Instance     Compute
storage.googleapis.com/Bucket   Storage
dataproc.googleapis.com/Cluster    DataProc Clusters
container.googleapis.com/Cluster   - GKE
cloudfunctions.googleapis.com/CloudFunction   Cloud Functions
dataflow.googleapis.com/Job  // for Notebook

gcloud asset search-all-resources --asset-types='compute.googleapis.com/Instance,storage.googleapis.com/Bucket' --query='labels.name:*' --format='table(name, assetType, labels)'”

anuj

I am passionate about getting cloud solutions right the first time. I help customers transition to the public cloud with the appropriate security controls and guardrails. GCP, AWS and Azure Security Specialist. <a href="https://calendly.com/anujvarma/google-cloud-architect-initial-consultation">Initial Consultation</a>

Leave a reply

Your email address will not be published. Required fields are marked *