Reputation: 403
In my Google Cloud console I have set a lot of labels on different kinds of Virtual machines. I want to clean up all the machines that have no label, since those aren't needed anymore. Is there an easy way to filter to get all those machines? When I want to filter now on labels I can only filter for each specific label.
Upvotes: 2
Views: 4219
Reputation: 3325
gcloud compute instances list --filter=-labels:*
will list the VM instance with no labels.
You obtain this combining the gcloud
command to list instances with the filter flag.
Note the -
after the equal sign, as this is the logic operator for NOT
when filtering in gcloud
. If you delete it, you get the list of instances with labels.
Upvotes: 4