How To Find and Delete Unattached GCP Disks

If you’re working within the Google Cloud Platform (GCP), locating and deleting unattached GCP disks is a critical to controlling costs and bolstering security. In this post, we'll walk through each step you can take to clean up wasteful resources.

Patrick Londa
Feb 2, 2022
 min read
Share this post

Many organizations have embraced moving their IT infrastructure to the cloud to enjoy benefits like lower overhead costs, increased redundancy, and better scalability. The tradeoff is that these organizations now need to monitor the incremental costs for things like compute time, data transfers, and storage capacity. If you’re working within the Google Cloud Platform (GCP), locating and deleting unattached GCP disks is a critical practice for optimizing your cloud infrastructure spending.

How Do You End Up With Unattached Disks?

Unattached GCP disks are abandoned or orphaned resources that are detached from a service and rendered inoperable. You can end up with an unattached disk, for example, by deleting a Google Compute Engine instance and orphaning a persistent disk that was once attached to it. This is helpful if you want to keep that data, but as an abandoned disk, your IT team will soon forget about its existence.

Why Is It Important To Delete Unattached GCP Disks?

GCP disks change as developers add new items to the GCP environment. Unfortunately, that often leads to disks ending up orphaned, which ends up hurting your company's bottom line. In 2020, idle resources contributed to more than $11 billion in wasted spending.

How Often Should You Remove Unattached GCP Disks?

Ideally, your company should have a GCP resource management plan in place for regular scanning of your GCP. By establishing scheduled removals, you’re consistently locating and removing unattached disks and other orphan resources. The more frequently you conduct your search, the less your organization will have to pay for unused or forgotten GCP resources.

The Blink platform helps IT organizations create practical, cost-effective applications that monitor cloud environments like GCP. That way, you can locate and track any unmanaged resources like unattached GCP disks.

Blink Automation: Detect Unattached GCP Disks and Send Report to Slack
GCP + Slack
Try This Automation

How Do You Find an Unattached GCP Disk?

You can find unattached GCP disks by connecting to Google Cloud and accessing Cloud Shell. You can also use tools like Blink to connect to Cloud Shell API using the service

Disks that are in use have a defined user. To locate disks that do not have an associated user, issue the following command:

gcloud compute disks list --filter="-users:*"

How Do You Delete Unattached GCP Disks?

To delete unattached GCP disks associated with a project, issue the following command in Cloud Shell:

gcloud compute disks delete $(gcloud compute disks list --filter="-users:*" --format "value(name)")

Before removing any resource from GCP, make sure it’s not needed. There may be situations where someone else in your IT department may require the information. The following command can help you locate any unattached GCP resources:

gcloud compute instances list [--project projectID] | grep TERMINATED

The above command is best suited for smaller environments. Teams should set up ongoing monitoring for more extensive operations. It’s also a good idea to use tools capable of more sophisticated detection techniques.

Optimizing GCP Costs Automatically with Blink

By finding a space to consolidate your GCP resource management, you put yourself in a better position to avoid the problem of unattached GCP disks. Automating your ability to locate and delete unused resources increases the efficiency of your operations and lowers your overall costs.

With Blink, you can run this automation to find unattached disks in your GCP account and send a report to a designated email address.

Blink Automation: Ensure Unused Disks are Removed in GCP
Blink Automation: Ensure Unused Disks are Removed in GCP

When this automation runs, it executes the following actions:

  1. Checks for unattached disks in your GCP account.
  2. Sends a report with the results via email.

You can import this automation from the Blink library and customize it however you like. For example, you could send a weekly Slack notification with a report on unattached disks, and add a step to approve their deletion via Slack.

In Blink, you can also create automations from scratch to meet your team’s unique needs using the hundreds of drag-and-drop actions available from a wide range of tools.

Sign up for a demo today to see how easy automation can be with Blink.

Automate your security operations everywhere.

Blink is secure, decentralized, and cloud-native. 
Get modern cloud and security operations today.

Get a Demo