您需要先启用 Cloud Asset Inventory API 并设置权限,然后才能使用 Cloud Asset Inventory。
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.
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-18。"],[[["\u003cp\u003eThis guide demonstrates how to use Cloud Asset Inventory and the Google Cloud CLI in Cloud Shell to view your assets within a Google Cloud project.\u003c/p\u003e\n"],["\u003cp\u003eBefore utilizing Cloud Asset Inventory, you must enable the Cloud Asset Inventory API and assign the Cloud Asset Owner role (\u003ccode\u003eroles/cloudasset.owner\u003c/code\u003e) to your user.\u003c/p\u003e\n"],["\u003cp\u003eYou can create a Compute Engine VM instance to practice viewing assets, then list all VM instances in your project using the \u003ccode\u003egcloud asset list\u003c/code\u003e command in Cloud Shell.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003egcloud asset list\u003c/code\u003e command allows filtering by asset types, such as \u003ccode\u003ecompute.googleapis.com/Instance\u003c/code\u003e for VM instances, and you can specify the \u003ccode\u003eresource\u003c/code\u003e content type to include detailed metadata.\u003c/p\u003e\n"],["\u003cp\u003eThis document includes cleanup instructions to avoid incurring charges, through deleting your created VM instance.\u003c/p\u003e\n"]]],[],null,["# View your assets\n================\n\nThis document shows you how to view your assets using Cloud Asset Inventory and the\nGoogle Cloud CLI in Cloud Shell.\n\nBefore you begin\n----------------\n\nBefore you can use Cloud Asset Inventory, you need to enable the Cloud Asset Inventory API and set up\npermissions.\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Cloud Asset Inventory API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=cloudasset.googleapis.com&redirect=https://console.cloud.google.com)\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Cloud Asset Inventory API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=cloudasset.googleapis.com&redirect=https://console.cloud.google.com)\n\n1. [Grant the following role to your user:](/iam/docs/granting-changing-revoking-access#single-role) Cloud Asset Owner (`roles/cloudasset.owner`).\n\nView your assets\n----------------\n\nIn a project of your choice, create a Compute Engine VM instance so that\nyou can view it in Cloud Asset Inventory:\n\n1. In the Google Cloud console, go to the **VM instances** page.\n\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n\n \u003cbr /\u003e\n\n2. Click **Create instance**.\n\n3. Enter a name for the instance.\n\n4. Click **Create**.\n\nList all the VM instances in your project:\n\n1. In the Google Cloud console, click\n terminal **Activate Cloud Shell**.\n\n2. In Cloud Shell, run the following command:\n\n gcloud asset list \\\n --project=\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e \\\n --asset-types=compute.googleapis.com/Instance \\\n --content-type=resource\n\n Replace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the ID of the project whose\n assets you want to list.\n\n In the previous code sample, an asset type of\n `compute.googleapis.com/Instance` is used to only list\n Compute Engine VM instances. To view all asset types, see\n [Asset types](/asset-inventory/docs/asset-types).\n\n A content type of `resource` has also been set. This specifies that\n `resource` metadata should also be returned in the response. If no\n content type is set, then only basic information about each asset is\n returned, such as the asset name, the last time it was updated, and what\n project it's in.\n\nClean up\n--------\n\n\nTo avoid incurring charges to your Google Cloud account for\nthe resources used on this page, follow these steps.\n\n1. In the Google Cloud console, go to the **VM instances** page.\n\n\n [Go to VM instances](https://console.cloud.google.com/compute/instances)\n\n \u003cbr /\u003e\n\n2. In the same row as the name of the VM instance you created, click\n more_vert **More actions**.\n\n3. Click **Delete**, and then confirm the deletion.\n\nWhat's next\n-----------\n\n- To explore more options related to viewing your assets, see [List assets](/asset-inventory/docs/list-assets)."]]