Reputation: 129
I am trying to check if a VPC Peering exists by filtering the gcloud output for the name of the peering, but can't quite get the gcloud command to work with my filter.... what I am trying to do is this:
gcloud compute networks peerings list --project=<project> --flatten="peerings" --filter="peerings.name:<the_peering_I_want_to_check_for>"
or
gcloud compute networks peerings list --project=<project> --flatten="peerings[].name" --filter="peerings.name:<the_peering_I_want_to_check_for>"
but both these returns the error:
Invalid value for field 'filter' ..... Invalid list filter expression
Have been following the suggestion on here - Filter on a custom list in response which talks about filtering for nested resources
This is an example of the output, that I want to retrive the peerings.name from
gcloud compute networks peerings list --project=<project> --format="flattened(peerings)"
---
peerings[0].importCustomRoutes: False
peerings[0].name: the_peering_I_want_to_check_for
peerings[1].importCustomRoutes: False
peerings[1].name: Antother_peering_that_i_don't_care_about_but_not_in_a_mean_way
Thanks!
Upvotes: 0
Views: 1229
Reputation: 404
This looks like an issue with the gcloud
command, I try to run the following command in the cloud shell:
gcloud compute networks peerings list --project=YOURPROJECT --filter='name eq PEERING NETWORK NAME THAT YOU WANT TO CHECK' --format json --log-http
and gcloud
returns an empty array, however we can see the command is sending the filter to the API and the API is returning the filtered list. It seems like the gcloud
command is removing the results after the response from the API.
If I use the API in this page I get a value in the array of the response, regardless if I use eq
or =
in the request. I created a public issue on Google's Issue Tracker so they can fix this issue.
Upvotes: 1