gcloud asset search-all-resources

NAME
gcloud asset search-all-resources - searches all Cloud resources within the specified accessible scope, such as a project, folder or organization
SYNOPSIS
gcloud 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
Searches all Cloud resources within the specified scope, such as a project, folder or organization. The caller must be granted the cloudasset.assets.searchAllResources permission on the desired scope.
EXAMPLES
To search all Cloud resources whose full resource name contains xyz as a prefix of any word, within organizations/123456, ensure the caller has been granted the cloudasset.assets.searchAllResources permission on the organization and run:
gcloud asset search-all-resources --scope='organizations/123456'  --query='name:xyz*'
FLAGS
--asset-types=[ASSET_TYPES,…]
A list of asset types to search. If not specified or empty, it will search all the searchable asset types. Example: cloudresourcemanager.googleapis.com/Project,compute.googleapis.com/Instance to search project and VM instance resources. Regular expressions are also supported. For example: compute.googleapis.com.* snapshots resources whose asset type starts with compute.googleapis.com. See RE2 for all supported regular expression syntax. If the regular expression does not match any supported asset type, an INVALID_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 DESC after the field name to indicate descending order. Redundant space characters are ignored. Example: location DESC, name. Only string fields in the response are sortable, including name, displayName, description and location.

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

  • The --order-by flag performs server-side sorting (better performance), while the --sort-by flag performs client-side sorting.
  • 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. See how to construct a query for more details. If not specified or empty, it will search all the resources within the specified scope.

Examples:

  • name:Important to find Cloud resources whose name contains Important as a word.
  • name=Important to find the Cloud resource whose name is exactly Important.
  • displayName:Impor* to find Cloud resources whose display name contains Impor as a prefix of any word.
  • location:us-west* to find Cloud resources whose location contains both us and west as prefixes.
  • labels:prod to find Cloud resources whose labels contain prod as a key or value.
  • labels.env:prod to find Cloud resources that have a label env and its value is prod.
  • labels.env:* to find Cloud resources that have a label env.
  • kmsKey:key to find Cloud resources encrypted with a customer-managed encryption key whose name contains key as a word.
  • state:ACTIVE to find Cloud resources whose state contains ACTIVE as a word.
  • createTime<1609459200 to find Cloud resources that were created before 2021-01-01 00:00:00 UTC. 1609459200 is the epoch timestamp of 2021-01-01 00:00:00 UTC in seconds.
  • updateTime>1609459200 to find Cloud resources that were updated after 2021-01-01 00:00:00 UTC. 1609459200 is the epoch timestamp of 2021-01-01 00:00:00 UTC in seconds.
  • Important to find Cloud resources that contain Important as a word in any of the searchable fields.
  • Impor* to find Cloud resources that contain Impor as a prefix of any word in any of the searchable fields.
  • Important location:(us-west1 OR global) to find Cloud resources that contain Important as a word in any of the searchable fields and are also located in the us-west1 region or the global location.
--scope=SCOPE
A scope can be a project, a folder, or an organization. The search is limited to the Cloud resources within this scope. The caller must be granted the cloudasset.assets.searchAllResources permission on the desired scope. If not specified, the configured project property will be used. To find the configured project, run: gcloud config get-value project. To change the setting, run: gcloud config 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 filter EXPRESSION to each resource item to be listed. If the expression evaluates True, then that item is listed. For more details and examples of filter expressions, run $ gcloud topic filters. This flag interacts with other flags that are applied in this order: --flatten, --sort-by, --filter, --limit.
--limit=LIMIT
Maximum number of resources to list. The default is unlimited. This flag 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 the maximum number of resources per page. The default is determined by the service if it supports paging, otherwise it is unlimited (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 order is ascending. Prefix a field with ``~´´ for descending order on that field. 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: --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 variant is also available:
gcloud beta asset search-all-resources