Reputation: 19342
I am trying to list my compute disks based on zone and name criteria.
However, the following command:
▶ gcloud compute disks list --filter="zone=europe-west4-a AND name=redash-postgres-data"
WARNING: --filter : operator evaluation is changing for consistency across Google APIs. zone=europe-west4-a currently does not match but will match in the near future. Run `gcloud topic filters` for details.
Listed 0 items.
a) does not return any results despite the fact that there IS such a disk
▶ gcloud compute disks list
NAME LOCATION LOCATION_SCOPE SIZE_GB TYPE STATUS
redash-postgres-data us-east4-b zone 50 pd-standard READY
gke-redash-test-cluster-redash-pool1-4db01a9f-1986 europe-west4-a zone 100 pd-standard READY
gke-redash-test-cluster-redash-pool1-4db01a9f-t34m europe-west4-a zone 100 pd-standard READY
redash-postgres-data europe-west4-a zone 60 pd-standard READY
b) how should we formulate the query so that we are future proof according to the above warning? the example I am using is from the help return by running gcloud topic filters
as suggested by the above warning message
Upvotes: 6
Views: 6387
Reputation: 9810
EDIT: The documentation that Kolban@ linked actually also mentions an alternative syntax that match a simple pattern and allows to use the short zone name:
--filter="zone:( us-east4-a )"
so your gcloud command can actually look like this:
gcloud compute disks list --filter="zone:( us-east4-a) AND name=redash-postgres-data"
When inspecting a disk resource via gcloud compute disks describe disk_name
, you'll see that, next to the other info, the zone is described like a fully qualified URL:
https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/us-east4-a
Filtering the list
command with this full URL will work:
gcloud compute disks list --filter="zone=https://www.googleapis.com/compute/v1/projects/PROJECT_NAME/zones/us-east4-a AND name=redash-postgres-data"
Upvotes: 8