Before you begin
Make sure you have gcloud CLI installed.
Checking for unused PD
To see all PD in a specific project with no user in order of descending creation time:
gcloud compute disks list --project=<project id> --sort-by="creationTimestamp desc" --filter="-users:*"
The filter can also be modified to find PD created in a specific time range, i.e. filter="-users:* AND creationTimestamp>2020-01-30"
More information on gcloud topic filters can be found in the gcloud CLI documentation.
Deleting unused PD
To delete all unused PD in a specific project and region:
DISKS=`gcloud --project=<project id> compute disks list --filter="-users:*" --format='value(name)'` && gcloud --project=<project-id> compute disks delete ${DISKS} --region=<region>