Skip to content

Instantly share code, notes, and snippets.

@n0531m
Last active April 4, 2019 06:13
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 n0531m/e7626791e5784d3812422a3cce086a94 to your computer and use it in GitHub Desktop.
Save n0531m/e7626791e5784d3812422a3cce086a94 to your computer and use it in GitHub Desktop.
GCP : Check project quota
#!/bin/bash
## lists project quota in use
## "jq" is required
## usage: ./checkquota.sh <PROJECTID>
PROJECT=$1
NOW=`date +%Y-%m-%d`
gcloud compute regions list --format json --project $PROJECT \
| jq -Sc ".[] | .name as \$region_name | .quotas[] | .scope=\$region_name | select (.usage>0.0) | .projectid=\"${PROJECT}\" | .date=\"${NOW}\" | .util=(.usage/.limit) "
gcloud compute project-info describe --format json --project $PROJECT \
| jq -Sc ".quotas[] | select (.usage>0.0) | .scope=\"global\" | .projectid=\"${PROJECT}\" | .date=\"${NOW}\" | .util=(.usage/.limit)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment