Google Cloud

Download 0
Last updated Oct 20, 2026

gcp-assets

Search resources under Google Cloud projects, folders or organizations using Cloud Asset Inventory API.

Syntax

gcp-assets [profile=STRING] [scope=STRING] [types=STRING] [query=STRING] [limit=INT] [verbose=BOOL]

Options

profile=STRING
Optional. Google Cloud connect profile. If multiple profiles are separated by commas, each profile is queried in turn and distinguished by the profile field. If not specified, all Google Cloud connect profiles you can use are queried. If an error occurs on a profile, rows already returned remain, the remaining profiles are skipped and the query ends with an error.
scope=STRING
Optional. projects/{id} (or projects/{number}), folders/{number} or organizations/{number}. Resources in the scope and below it (including sub folders and projects) are returned. Project of JSON key is used if not specified.
types=STRING
Optional. Comma separated asset types. Regular expression is supported. e.g. compute.googleapis.com/Instance, iam.googleapis.com/.*. All types are returned if not specified. See the asset type table in Description for common types.
query=STRING
Optional. Search query of Cloud Asset Inventory. e.g. labels.env:prod, location:asia-northeast3, name:sinks. Terms containing characters other than English letters and digits must be enclosed in double quotes, written as \" in the option value. e.g. query="tagKeys:\"dev-team\"". See Cloud Asset Inventory query syntax.
limit=INT
Optional. Max number of rows per profile. Positive integer. All rows are returned if not specified.
verbose=BOOL
Optional. Include versioned_resources and attached_resources. t, f, true or false (default: f)

Output fields

FieldTypeNameDescription
profileStringProfileConnect profile name
asset_typeStringAsset typee.g. compute.googleapis.com/Instance
display_nameStringDisplay nameDisplay name of the resource
project_idStringProject IDUser assigned project ID. Empty if the resource does not belong to a project (e.g. organization or folder)
project_nameStringProject nameDisplay name of the project. Empty if the resource does not belong to a project (e.g. organization or folder)
locationStringLocatione.g. global, us-central1
stateStringStateState of the resource. e.g. RUNNING, ACTIVE, ENABLED
create_timeDateCreated atCreate time of the resource. Only resources that provide it have a value
update_timeDateUpdated atLast update time of the resource. Only resources that provide it have a value
nameStringNameFull resource name. e.g. //compute.googleapis.com/projects/p1/zones/z1/instances/i1
descriptionStringDescriptionDescription of the resource. Only resources with a description have a value
labelsMapLabelsUser defined labels
tagsListTagsTags directly attached to the resource. Each item has tagKey, tagKeyId, tagValue and tagValueId
effective_tagsListEffective tagsTags attached or inherited from ancestors, grouped by attachedResource
network_tagsListNetwork tagsNetwork tags of Compute Engine resources
kms_keysListKMS keysCloud KMS keys used to encrypt the resource
projectStringProjectProject in projects/{number} form. Empty for organization and folder resources
foldersListFoldersAncestor folders in folders/{number} form, nearest first
organizationStringOrganizationOrganization in organizations/{number} form
parent_asset_typeStringParent typeAsset type of the parent
parent_full_resource_nameStringParentFull resource name of the parent
additional_attributesMapAdditional attributesAsset type specific attributes. e.g. projectId of a project
versioned_resourcesListVersioned resourcesFull configuration of the resource by API version, as returned by Cloud Asset Inventory. Only with verbose=t
attached_resourcesListAttached resourcesAttached resources such as Compute Engine OS inventory, as returned by Cloud Asset Inventory. Only with verbose=t

Error codes

Parse errors

Error messageCauseSolution
No available Google Cloud profile found.Wrong profile code or no permission to use the profileSpecify the connect profile code in the profile option and check the profile permission
Invalid scope: {scope}Invalid scope format, or a folder or organization specified by nameSpecify an ID or number after projects/, folders/ or organizations/
limit should be positive integer: {limit}limit is 0 or less, or not a numberSpecify a positive integer
verbose should be t, f, true or false: {verbose}Invalid verbose valueSpecify t, f, true or false

Runtime errors

Error messageCauseSolution
HTTP 403: PERMISSION_DENIED - The caller does not have permissionNo Cloud Asset Viewer role on the scopeCheck with gcp-check-permissions and grant the role on the scope
HTTP 403: PERMISSION_DENIED - Cloud Asset API has not been used in project ...Cloud Asset API is not enabled in the project of the service accountEnable Cloud Asset API in the project the service account belongs to
HTTP 400: INVALID_ARGUMENT - Invalid query syntax, Unsupported field: ...Invalid query syntax or unsupported fieldFix the query referring to the supported fields in the message and the query syntax document
HTTP 400: INVALID_ARGUMENT - Please quote term ... with double quotesA query term with special characters is not quotedEnclose the term with "
HTTP 400: INVALID_ARGUMENT - No supported asset type matches: ...types contains an unsupported or unknown asset typeCheck the supported asset types
token exchange failed, HTTP 400: Invalid grantWrong JSON key, or the service account or key was deletedCreate a new key and update the connect profile

Description

Searches resource metadata in the scope using searchAllResources API of Cloud Asset Inventory. If an organization or folder is specified, resources in all folders and projects below it are returned. Results are fetched up to 500 at a time until the end.

The API returns the containing project as a number (projects/{number}) only. To make it readable, the command queries projects in the same scope once more and fills project_id and project_name. Folders and organization are returned as numbers only (folders, organization). To find their names, query with types="cloudresourcemanager.googleapis.com/(Folder|Organization)".

Specify IDs or numbers, not display names, in scope. Display names of folders and projects may be duplicated or changed, so specifying a name could query an unintended scope. Use the following query to find organization and folder numbers.

gcp-assets profile=gcp types="cloudresourcemanager.googleapis.com/(Organization|Folder|Project)"
| fields asset_type, display_name, name, organization
Note
Results are the recent inventory collected by Google Cloud, not the real-time state. Changes are reflected after a few minutes to a few hours depending on the asset type. Data inside resources (bucket objects, database contents) and IAM policies are not returned. Use gcp-iam-policies for IAM policies.

query is passed to Google Cloud as is without validation in the app. For an invalid query, Google Cloud returns an INVALID_ARGUMENT error with the cause, which is shown as the query error.

With verbose=t, the full configuration that differs by asset type is also returned, so the response gets larger. For a large scope, increase the read timeout of the connect profile or narrow the scope with types.

Common asset types

Frequently used asset types for the types option. See Supported asset types for the full list. An unknown or misspelled type causes a No supported asset type matches error.

CategoryAsset typeResource
Computecompute.googleapis.com/InstanceVM instance
Computecompute.googleapis.com/DiskPersistent disk
Computecontainer.googleapis.com/ClusterGKE cluster
Computerun.googleapis.com/ServiceCloud Run service
Computecloudfunctions.googleapis.com/FunctionCloud Functions (2nd gen)
Networkcompute.googleapis.com/FirewallFirewall rule
Networkcompute.googleapis.com/NetworkVPC network
Networkcompute.googleapis.com/SubnetworkSubnet
Networkcompute.googleapis.com/AddressReserved IP address
Networkdns.googleapis.com/ManagedZoneCloud DNS zone
Storage and databasestorage.googleapis.com/BucketCloud Storage bucket
Storage and databasesqladmin.googleapis.com/InstanceCloud SQL instance
Storage and databasebigquery.googleapis.com/DatasetBigQuery dataset
Security and identityiam.googleapis.com/ServiceAccountService account
Security and identityiam.googleapis.com/ServiceAccountKeyService account key
Security and identityiam.googleapis.com/RoleCustom role
Security and identitycloudkms.googleapis.com/CryptoKeyCloud KMS key
Security and identitysecretmanager.googleapis.com/SecretSecret Manager secret
Security and identityorgpolicy.googleapis.com/PolicyOrganization policy
Resource hierarchycloudresourcemanager.googleapis.com/OrganizationOrganization
Resource hierarchycloudresourcemanager.googleapis.com/FolderFolder
Resource hierarchycloudresourcemanager.googleapis.com/ProjectProject
Operationsserviceusage.googleapis.com/ServiceEnabled API
Operationslogging.googleapis.com/LogSinkLog sink

Multiple types can be specified with a regular expression. e.g. types="compute.googleapis.com/.*" (all Compute Engine), types="iam.googleapis.com/.*" (all IAM)

Examples

Example: Asset types in the organization

Situation: Find what kinds of resources exist in the organization and how many.

gcp-assets profile=gcp scope=organizations/123456789012
| stats count by asset_type
| sort -count

Expected result:

asset_typecount
serviceusage.googleapis.com/Service52
logging.googleapis.com/LogBucket8
logging.googleapis.com/LogSink8
iam.googleapis.com/ServiceAccountKey3
cloudresourcemanager.googleapis.com/Project2

Interpretation: Number of resources by asset type. serviceusage.googleapis.com/Service is an API enabled in each project. Use the types option to see a specific type only.

Example: Service accounts and keys

Situation: Review service accounts and service account keys in the organization by project.

gcp-assets profile=gcp scope=organizations/123456789012 types="iam.googleapis.com/.*"
| fields project_id, asset_type, display_name, name, create_time

Expected result:

project_idasset_typedisplay_namenamecreate_time
my-project-123456iam.googleapis.com/ServiceAccountlogpresso//iam.googleapis.com/projects/my-project-123456/serviceAccounts/...
my-project-123456iam.googleapis.com/ServiceAccountKeyprojects/my-project-123456/serviceAccounts/.../keys/...//iam.googleapis.com/projects/my-project-123456/serviceAccounts/.../keys/...2026-10-19 14:02:13+0900

Interpretation: Check for unused service accounts or old keys.

Example: Resources with a tag

Situation: Find resources that have a tag directly attached or inherited.

gcp-assets profile=gcp scope=organizations/123456789012 query="effectiveTagKeys:\"dev-team\""
| stats count by project_id, asset_type

Interpretation: The project the tag is attached to and all resources below it are returned. Use tagKeys: to find directly attached resources only.

Example: All projects in the organization including sub folders

Situation: scope of gcp-projects returns direct child projects only, so use this command to list all projects in the organization including sub folders.

gcp-assets profile=gcp scope=organizations/123456789012 types="cloudresourcemanager.googleapis.com/Project"
| fields project_id, display_name, folders, state, create_time

Interpretation: Folder numbers (folders) and state of each project are returned.