cloud jockey
cloud jockey

Reputation: 258

List internal IP addresses of GCE Instance groups

I was trying to automate outputting the Internal IP Addresses of instances that are created as part of Managed Instance groups (MIG) in Google cloud Compute engine. This was the closest documentation I could see: https://cloud.google.com/compute/docs/instances/view-ip-address#gcloud

Upvotes: 1

Views: 609

Answers (1)

cloud jockey
cloud jockey

Reputation: 258

For MIGs (no external IP) created for a Region:

gcloud compute instance-groups list-instances my-test-ig-regional \
--region=us-central1 \
--uri | xargs -I '{}' gcloud compute instances describe '{}' \
--flatten networkInterfaces \
--format 'csv[no-heading](name,networkInterfaces.networkIP)'

For MIGs (no external IP) created for a zone:

gcloud compute instance-groups list-instances my-test-ig-zonal \
--zone=us-central1-a \
--uri | xargs -I '{}' gcloud compute instances describe '{}' \
--flatten networkInterfaces \
--format 'csv[no-heading](name,networkInterfaces.networkIP)'

Upvotes: 2

Related Questions