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.
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 cloudshell.googleapis.com.
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.
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.
Top comments (0)