Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Assets ansehen
In diesem Dokument erfahren Sie, wie Sie Ihre Assets mit Cloud Asset Inventory und der Google Cloud CLI in Cloud Shell ansehen.
Hinweise
Bevor Sie Cloud Asset Inventory verwenden können, müssen Sie die Cloud Asset Inventory API aktivieren und Berechtigungen einrichten.
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.
Ersetzen Sie PROJECT_ID durch die ID des Projekts, dessen Assets Sie auflisten möchten.
Im vorherigen Codebeispiel wird der Asset-Typ compute.googleapis.com/Instance verwendet, um nur Compute Engine-VM-Instanzen aufzulisten. Eine Liste aller Asset-Typen finden Sie unter Asset-Typen.
Außerdem wurde der Inhaltstyp resource festgelegt. Gibt an, dass auch resource-Metadaten in der Antwort zurückgegeben werden sollen. Wenn kein Inhaltstyp festgelegt ist, werden nur grundlegende Informationen zu jedem Asset zurückgegeben, z. B. der Asset-Name, der Zeitpunkt der letzten Aktualisierung und das Projekt, in dem sich das Asset befindet.
Bereinigen
Mit den folgenden Schritten vermeiden Sie, dass Ihrem Google Cloud -Konto die auf dieser Seite verwendeten Ressourcen in Rechnung gestellt werden:
Rufen Sie in der Google Cloud Console die Seite VM-Instanzen auf:
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-08-18 (UTC)."],[[["\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)."]]