gcloud beta asset search-all-resources

NAME
gcloud beta asset search-all-resources - searches all Cloud resources within the specified accessible scope, such as a project, folder or organization
SYNOPSIS
gcloud beta asset search-all-resources[--asset-types=[ASSET_TYPES,…]][--order-by=ORDER_BY][--query=QUERY][--scope=SCOPE][--filter=EXPRESSION][--limit=LIMIT][--page-size=PAGE_SIZE][--sort-by=[FIELD,…]][GCLOUD_WIDE_FLAG]
DESCRIPTION
(BETA) Searches all Cloud resources within the specified scope,such as a project, folder or organization. The caller must be granted thecloudasset.assets.searchAllResourcespermission on the desired scope.
EXAMPLES
To search all Cloud resources whose full resource name containsxyz as a prefix of any word, withinorganizations/123456, ensure the caller hasbeen granted thecloudasset.assets.searchAllResourcespermission on the organization and run:
gcloudbetaassetsearch-all-resources--scope='organizations/123456'--query='name:xyz*'
FLAGS
--asset-types=[ASSET_TYPES,…]
A list of asset types that this request searches for. If empty, it will searchall thesearchableasset types.

Regular expressions are also supported. For example:

  • compute.googleapis.com.* snapshotsresources whose asset type starts withcompute.googleapis.com.
  • .*Instance snapshots resources whose assettype ends withInstance.
  • .*Instance.* snapshots resources whoseasset type containsInstance.

SeeRE2 for allsupported regular expression syntax. If the regular expression does not matchany supported asset type, anINVALID_ARGUMENT error will be returned.

--order-by=ORDER_BY
A comma-separated list of fields specifying the sorting order of the results.The default order is ascending. Add DESCafter the field name to indicate descending order. Redundant space charactersare ignored. Example:location DESC, name.Only singular primitive fields in the response are sortable:
  • name
  • assetType
  • project
  • displayName
  • description
  • location
  • createTime
  • updateTime
  • state
  • parentFullResourceName
  • parentAssetType

All the other fields such as repeated fields (e.g.,networkTags,kmsKeys), map fields (e.g.,labels) and struct fields(e.g.,additionalAttributes) are not supported.

Both--order-by and--sort-by flags can be used tosort the output, with the following differences:

  • The--order-by flag performs server-side sorting (betterperformance), while the--sort-by flag performs client-sidesorting.
  • The--sort-by flag supports all the fields in the output, while the--order-by flag only supports limited fields as shown above.
--query=QUERY
The query statement. Seehowto construct a query for more details. If not specified or empty, it willsearch all the resources within the specifiedscope.

Examples:

  • name:Important to find Cloud resources whose name containsImportant as a word.
  • name=Important to find the Cloud resource whose name is exactlyImportant.
  • displayName:Impor* to find Cloud resources whose display namecontainsImpor as a prefix of any word.
  • location:us-west* to find Cloud resources whose location containsbothus andwest as prefixes.
  • labels:prod to find Cloud resources whose labels containprod as a key or value.
  • labels.env:prod to find Cloud resources that have a labelenv and its value isprod.
  • labels.env:* to find Cloud resources that have a labelenv.
  • tagKeys:env to find Cloud resources that are directly attached totags where the`TagKey.namespacedName`containsenv.
  • tagValues:prod* to find Cloud resources that are directly attachedto tags where the`TagValue.namespacedName`contains a word prefixed byprod.
  • tagValueIds=tagValues/123 to find Cloud resources that are directlyattached to tags where the`TagValue.name`is exactlytagValues/123.
  • effectiveTagKeys:env to find Cloud resources that are directlyattached to or inherited tags where the`TagKey.namespacedName`containsenv.
  • effectiveTagValues:prod* to find Cloud resources that are directlyattached to or inherited tags where the`TagValue.namespacedName`contains a word prefixed byprod.
  • effectiveTagValueIds=tagValues/123 to find Cloud resources that aredirectly attached to or inherited tags where the`TagValue.name`is exactlytagValues/123.
  • kmsKey:key to find Cloud resources encrypted with acustomer-managed encryption key whose name containskey as a word. This field is deprecated.Please use thekmsKeys field to retrieve KMS key information.
  • kmsKeys:key to find Cloud resources encrypted with customer-managedencryption keys whose name contains the wordkey.
  • relationships:instance-group-1 to find Cloud resources that haverelationships withinstance-group-1 in therelated resource name.
  • relationships:INSTANCE_TO_INSTANCEGROUP to find Compute instancesthat have relationships of typeINSTANCE_TO_INSTANCEGROUP.
  • relationships.INSTANCE_TO_INSTANCEGROUP:instance-group-1 to findCompute instances that have relationships withinstance-group-1 in the Compute instancegroup resource name, for relationship typeINSTANCE_TO_INSTANCEGROUP.
  • sccSecurityMarks.key=value to find Cloud resources that areattached with security marks whose key iskey and value isvalue.
  • sccSecurityMarks.key:* to find Cloud resources that are attachedwith security marks whose key iskey.
  • state:ACTIVE to find Cloud resources whose state containsACTIVE as a word.
  • NOT state:ACTIVE to find Cloud resources whose state doesn'tcontainACTIVE as a word.
  • createTime<1609459200 orcreateTime<2021-01-01orcreateTime<"2021-01-01T00:00:00" to find Cloud resources thatwere created before2021-01-01 00:00:00UTC. 1609459200 is the epoch timestamp of2021-01-01 00:00:00 UTC in seconds.
  • updateTime>1609459200 orupdateTime>2021-01-01orupdateTime>"2021-01-01T00:00:00" to find Cloud resources thatwere updated after2021-01-01 00:00:00 UTC.1609459200 is the epoch timestamp of2021-01-01 00:00:00UTC in seconds.
  • Important to find Cloud resources that containImportant as a word in any of thesearchable fields.
  • Impor* to find Cloud resources that containImpor as a prefix of any word in any of thesearchable fields.
  • Important location:(us-west1 OR global) to find Cloud resourcesthat containImportant as a word in any ofthe searchable fields and are also located in theus-west1 region or theglobal location.
--scope=SCOPE
A scope can be a project, a folder, or an organization. The search is limited tothe Cloud resources within this scope. The caller must be granted thecloudasset.assets.searchAllResourcespermission on the desired scope. If not specified, theconfiguredproject property will be used. To find the configured project, run:gcloud config get project. To change the setting, run:gcloudconfig set project PROJECT_ID.

The allowed values are:

  • projects/{PROJECT_ID} (e.g.,projects/foo-bar)
  • projects/{PROJECT_NUMBER} (e.g.,projects/12345678)
  • folders/{FOLDER_NUMBER} (e.g.,folders/1234567)
  • organizations/{ORGANIZATION_NUMBER} (e.g.organizations/123456)
LIST COMMAND FLAGS
--filter=EXPRESSION
Apply a Boolean filterEXPRESSION to each resource itemto be listed. If the expression evaluatesTrue, then that item islisted. For more details and examples of filter expressions, run $gcloud topic filters. This flaginteracts with other flags that are applied in this order:--flatten,--sort-by,--filter,--limit.
--limit=LIMIT
Maximum number of resources to list. The default isunlimited. Thisflag interacts with other flags that are applied in this order:--flatten,--sort-by,--filter,--limit.
--page-size=PAGE_SIZE
Some services group resource list output into pages. This flag specifies themaximum number of resources per page. The default is determined by the serviceif it supports paging, otherwise it isunlimited (no paging).Paging may be applied before or after--filter and--limit depending on the service.
--sort-by=[FIELD,…]
Comma-separated list of resource field key names to sort by. The default orderis ascending. Prefix a field with ``~´´ for descending order on thatfield. This flag interacts with other flags that are applied in this order:--flatten,--sort-by,--filter,--limit.
GCLOUD WIDE FLAGS
These flags are available to all commands:--access-token-file,--account,--billing-project,--configuration,--flags-file,--flatten,--format,--help,--impersonate-service-account,--log-http,--project,--quiet,--trace-token,--user-output-enabled,--verbosity.

Run$gcloud help for details.

NOTES
This command is currently in beta and might change without notice. This variantis also available:
gcloudassetsearch-all-resources

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-05-07 UTC.