Created
August 14, 2022 13:29
-
-
Save vadirajks/cf1b1871010d748046dbfb291eb363b7 to your computer and use it in GitHub Desktop.
gcp-instance-group_details.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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