Skip to content

Instantly share code, notes, and snippets.

@vadirajks
Created August 14, 2022 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vadirajks/cf1b1871010d748046dbfb291eb363b7 to your computer and use it in GitHub Desktop.
Save vadirajks/cf1b1871010d748046dbfb291eb363b7 to your computer and use it in GitHub Desktop.
gcp-instance-group_details.sh
IFS=$'\n'
echo "INSTANCE-GROUPS,LOCATION,SCOPE,INSTANCE-TEMPLATES,IMAGE"
for ig in $(gcloud compute instance-groups list | grep -v "^dataflow\|^NAME\|^gke"); do
result=$(echo $ig|awk 'BEGIN { OFS="," }{print $2,$3}')
tmresult=$(gcloud compute instance-groups managed describe $(echo $ig|awk '{print $1}') --zone $(echo $ig|awk '{print $2}') --format=json | jq -r "[.instanceGroup,.instanceTemplate]|@csv")
for i in $(echo ${tmresult}) ; do
set $(echo $i | tr "," "\n"|tr -d '"')
image=$(gcloud compute instance-templates describe ${2##*/} --format=json | jq -r ".properties|.disks[].initializeParams.sourceImage")
echo ${1##*/},$result,${2##*/},${image##*/}
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment