This command gives me the instance name:
curl -X GET http://metadata.google.internal/computeMetadata/v1/instance/name -H 'Metadata-Flavor: Google'
This command gives me the instance zone:
curl -X GET http://metadata.google.internal/computeMetadata/v1/instance/zone -H 'Metadata-Flavor: Google
I can't figure out how to get the instance-group-name similarly?
I need this set self-destruct command in a GCE instance:
gcloud compute instance-groups managed delete-instances $INSTANCE_GROUP_NAME --instances=$NAME --zone=$ZONE
Looking at this document:
https://cloud.google.com/compute/docs/instance-groups/getting-info-about-migs#checking_if_a_vm_instance_is_part_of_a_mig
There appears to be a metadata key value called "created-by". This appears to have a value similar to:
projects/123456789012/zones/us-central1-f/instanceGroupManagers/igm-metadata
Looking at this, we can appear to parse the string and the value following "instanceGroupManagers" appears to provide the information we are looking for.