I want to get all instance id or list of all instance based on tag in GCP compute engine using Google compute engine sdk.
Can someone guide me how i can do this?
I want to get all instance id or list of all instance based on tag in GCP compute engine using Google compute engine sdk.
Can someone guide me how i can do this?
Copyright © 2021 Jogjafile Inc.
You can filter results from list commands with regular expressions by including the --filter flag as shown in this official GCP document.
Use the filter in command as shown below:
“gcloud compute instances list --filter="tags:tag1"”Replace “tag1” in the above command with the tag you have used for your instances so that you will get only instances with the mentioned tag.