The google cloud API for compute.instances.aggregatedList includes filter argument. https://cloud.google.com/compute/docs/reference/rest/beta/instances/aggregatedList
I use (status eq "RUNNING") as a filter to view all my running instances.
I would like to have a more elaborate criteria, such as one that uses labels and or other terms, however even the Google documentation terms (that use OR operator) returns an error, For example - even Google documentation example: (cpuPlatform = "Intel Skylake") OR (cpuPlatform = "Intel Broadwell") fails with error 400:
"message": "Invalid value for field 'filter': ' (cpuPlatform = \"Intel Skylake\") OR (cpuPlatform = \"Intel Broadwell\")'. Invalid list filter expression."
it looks as if the '=' signs are not accepted, and AND/OR operators are not accepted. What is the correct format for this API.
A stopped instance does not incur charges, but all of the resources that are attached to the instance will still be charged. For example, you are charged for persistent disks and external IP addresses according to the price sheet, even if an instance is stopped.
In the Google Cloud console, go to the VM instances page. Select one or more VMs that you want to stop. Click Stop.
By default, Cloud Run services are configured to scale out to a maximum of 100 instances. You can change the maximum instances setting using the Google Cloud console, the gcloud command line, or a YAML file when you create a new service or deploy a new revision.
I had the same issue when I used "=" instead of "eq" in google-api-python-client. I required to use labels to filter the aggregated instances list. At first I used
filter="labels.projectid=test-project"
which returned 400 error in aggregated list but was successful if it was queried for instances of specific zone.
I achieved the list successfully when I used filter as
filter="labels.projectid eq \"test-project\""
or
filter = "labels.projectid eq test-project"
I even tested it using REST-Client provided by google and it worked. Reference: https://issuetracker.google.com/80238913
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With