View your assets
This document shows you how to view your assets using Cloud Asset Inventory and the Google Cloud CLI in Cloud Shell.
Before you begin
Before you can use Cloud Asset Inventory, you need to enable the Cloud Asset Inventory API and set up permissions.
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Cloud Asset Inventory API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Cloud Asset Inventory API.
-
Grant the following role to your user:
Cloud Asset Owner (
roles/cloudasset.owner
).
View your assets
In a project of your choice, create a Compute Engine VM instance so that you can view it in Cloud Asset Inventory:
In the Google Cloud console, go to the VM instances page.
Click Create instance.
Enter a name for the instance.
Click Create.
List all the VM instances in your project:
In the Google Cloud console, click
Activate Cloud Shell.In Cloud Shell, run the following command:
gcloud asset list \ --project=PROJECT_ID \ --asset-types=compute.googleapis.com/Instance \ --content-type=resource
Replace
PROJECT_ID
with the ID of the project whose assets you want to list.In the previous code sample, an asset type of
compute.googleapis.com/Instance
is used to only list Compute Engine VM instances. To view all asset types, see Asset types.A content type of
resource
has also been set. This specifies thatresource
metadata should also be returned in the response. If no content type is set, then only basic information about each asset is returned, such as the asset name, the last time it was updated, and what project it's in.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
In the Google Cloud console, go to the VM instances page.
In the same row as the name of the VM instance you created, click
More actions.Click Delete, and then confirm the deletion.
What's next
- To explore more options related to viewing your assets, see List assets.