01 Run projects list command (Windows/macOS/Linux) using custom query filters to list the IDs of all the Google Cloud Platform (GCP) projects available in your cloud account:
gcloud projects list
--format="table(projectId)"
02 The command output should return the requested GCP project IDs:
PROJECT_ID
cc-web-stack-project-123123
cc-backend-app-project-112233
03 Run compute disks list command (Windows/macOS/Linux) with the ID of the GCP project that you want to examine as the identifier parameter and custom query filters to describe the name and zone for each persistent disk provisioned for the selected project:
gcloud compute disks list
--project cc-web-stack-project-123123
--format="table(name,zone)"
04 The command output should return the identifier(s) of the disk(s) available within the selected GCP project:
NAME: cc-staging-vm-boot
ZONE: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a
NAME: cc-staging-vm-data
ZONE: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a
NAME: cc-production-vm-boot
ZONE: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-c
NAME: cc-production-vm-data
ZONE: https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-c
05 Run compute disks describe command (Windows/macOS/Linux) using the name and the zone of the persistent disk that you want to examine as the identifier parameter and custom filtering to describe the ID of the VM instance associated with the selected disk:
gcloud compute disks describe cc-staging-vm-boot
--zone us-central1-a
--format="value(users)"
06 The command output should return the ID of the associated VM instance:
https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a/instances/cc-staging-vm-instance
07 Run compute instances describe command (Windows/macOS/Linux) using the name and the zone of the instance that you want to examine as the identifier parameter, to describe the current status of the VM instance associated with your persistent disk:
gcloud compute instances describe https://www.googleapis.com/compute/v1/projects/cc-web-stack-project-123123/zones/us-central1-a/instances/cc-staging-vm-instance
--zone us-central1-a
--format="value(status)"
08 The command output should return the current state of the VM instance:
If the
compute instances describe command output returns
SUSPENDING or
SUSPENDED, as shown in the example above, the selected disk is attached to a suspended virtual machine (VM) instance, therefore, the unused disk is adding charges to your Google Cloud bill.
09 Repeat steps no. 5 - 8 for each persistent disk provisioned for the selected GCP project.
10 Repeat steps no. 3 – 9 for each GCP project deployed in your Google Cloud account.