Google Cloud CLI

When working with gcloud CLI, sometimes there are strong needs to filter and format the output for subsequent processing.

A use case for example here:

1
2
3
4
5
gcloud compute instances \
list \
--project example \
--filter='name~test*' \
--format="value(name,zone,disks[].deviceName)"

They are all from gcloud topic group, from the leftside panel there are other gcloud command reference.

Resource Available Key

To find the keys for filter and format, check --format flattened option, it will list all keys for the specified resource.

Filter Syntax

https://cloud.google.com/sdk/gcloud/reference/topic/filters

Format Syntax

https://cloud.google.com/sdk/gcloud/reference/topic/formats

Projection Syntax:

https://cloud.google.com/sdk/gcloud/reference/topic/projections

0%