Skip to content

Instantly share code, notes, and snippets.

@Chan9390
Created May 10, 2019 15:09
Show Gist options
  • Save Chan9390/e639997ad577d1f7499fa1adf5d50857 to your computer and use it in GitHub Desktop.
Save Chan9390/e639997ad577d1f7499fa1adf5d50857 to your computer and use it in GitHub Desktop.
echo Project Name,Disk Name,Source Image
for projectname in `gcloud projects list --format json | jq -r '.[].projectId'`; do
gcloud compute disks list -q --project $projectname --format json | \
jq -r '.[] | ["\(.name)", "\(.sourceImage)"] | @tsv' | \
while IFS=$'\t' read -r diskname sourceimage; do
os=`echo $sourceimage | awk -F "/" '{print $NF}'`;
echo $projectname,$diskname,$os;
done;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment