1#!/bin/bash
2
3zoneMetadata=$(curl "http://metadata.google.internal/computeMetadata/v1/instance/zone" -H "Metadata-Flavor:Google")
4# Split on / and get the 4th element to get the actual zone name
5IFS=$'/'
6zoneMetadataSplit=($zoneMetadata)
7zone="${zoneMetadataSplit[3]}"
8
9echo $(hostname)
10echo $zone
11
12gcloud compute instances delete $(hostname) --zone=$zone --quiet
13