I wanted to fetch all the resources(VM instances,VPS,Storage,etc) under my Gcloud account irrespective of project and region through API.
2 Answers
The answer depends on what you mean by all the resources under "my Gcloud account".
If you have the cloudasset.assets.searchAllResources
permission upon an organization, you can list all the resources under the org using search-all-resources:
$ gcloud asset search-all-resources --scope=organizations/123
Similarly, you can list resources for a folder or a project using the same command.
More details can be found in another post: How to find, list, or search resources across services (APIs) and projects in Google Cloud Platform?

- 1,058
- 11
- 15
The answer depends on what you mean by "my Gcloud account" and what permissions (IAM Roles) your account credentials have.
To list all of the resources across all Google Cloud projects that your credentials have access to, use the resources
CLI command. Note that this is an alpha
command and is not a production feature yet. This command also might require whitelisting by Google to use (I am not sure for this command).
gcloud alpha resources list --format json
This command is an alpha
feature and requires optional components to be installed to use the command. This requires elevation (sudo on Linux):
gcloud components install alpha
I recommend updating to the latest CLI version as the final step. This requires elevation (sudo on Linux):
gcloud components update

- 74,467
- 6
- 95
- 159
-
Thank You for your time, let me give you some more clarity . For an example using below API i can get list of projects under my GCloud Account( Gmail-Id which is having the GCloud subscription) . So now i want to retrieve all the resources( VMs,Storage,VPN,VPS,etc) under my account using Rest API. Purpose : i want to retrieve all the resource through the api by using Microservice(SpringBoot/NodeJS). – vivek java Mar 17 '20 at 09:56
-
Will that be possible by making any API call? Suppose I can get a list of all resource types using stackdriver's monitoring API in Python. Do we have any similar API services that can fetch all the active resources with their metadata for a project? – Namballa Mukesh Mar 07 '23 at 09:27