Whitepaper 'FinOps and cost management for Kubernetes'
OptScale is fully available as an open source solution under Apache 2.0 on GitHub
Ebook 'From FinOps to proven cloud cost management & optimization strategies'

Reduce your AWS bill by eliminating orphaned and unused disk snapshots

Share on linkedin
Share on twitter
Share on facebook

Problem description

AWS volume snapshots, also known as EBS snapshots, are widely used to backup and restore data on Amazon EC2, being how important it is nowadays to stay protected. But, how are these snapshots charged? How much does it cost me to remain protected? Can I somehow reduce my AWS bill by removing unused resources? In this article, we will answer each of these questions with insightful answers.

Mismanaged cloud resources and unpredictable cloud bills are not a myth. IT leaders are facing this common problem on a daily basis. A lack of transparency could be one of the main obstacles, which precludes analyzing and optimizing the costs of your AWS cloud. Visibility is a key to optimization and having a clearly defined FinOps strategy in place aims to bring more transparency, prevent budget overruns, and identify wasted budget and idle resources, such as orphaned and unused disk snapshots.

How AWS volume snapshots are charged

EBS snapshots are charged on a gigabyte-per-month basis, thus an important takeaway here is to understand how they are generated, and how much storage they consume in reality.

AWS snapshots are stored incrementally. This means that the first snapshot of your instance is a full copy, and each additional snapshot is incremental, so only the changed parts, or deltas, of your EBS volume are stored.

Reduce-AWS-bill-by-cleaning-orphaned-snapshots

Let’s take a look at an example of this: here is a 200GB instance running in your account. The first snapshot that you create will also be 200GB, and you will be charged for this amount of data. If you have 205 GB of extra data, emulating a case in which the initial 200GB was not changed, the next time you create a snapshot, you will be charged for an additional 5GB of snapshot storage for the second snapshot.

Free cloud cost optimization for a lifetime

Why companies continue to pay after deleting an instance in AWS

The next thing to remember is that when an instance in AWS is deleted, the volume of this instance is also deleted, but the snapshots remain in the cloud. Therefore, they become orphaned and are often just lost among the others. However, you still have to pay for them.

As for all other AWS services, the pricing also varies from one region to another. The average price, however, is approximately $0.05 per GB-month of data stored. Some would say that this is not that much to pay, and he may be right, but here is where the main issue comes in – the more snapshots you have, the higher your bill becomes.

Obviously, the optimal solution to this issue is to have a policy available that would describe how you store and retain unused snapshots and scripts, to then find and clean them up.

OptScale, a FinOps and cloud cost management platform, is available on cloud marketplaces

AWS-logo
azure
Alibaba Cloud marketplace
Digital-ocean

How to find and delete orphaned and unused snapshots

The process of finding orphaned snapshots is a bit complex. The reason for the complexity is that you have not only to get the list of snapshots, but also to get the list of volumes/AMIs, and check whether the snapshots are linked or not to particular volumes and images.

From the AWS Console:

The AWS Console is pretty poor at identifying if a snapshot is related to any existing AMI or volume. For example, even if a volume is deleted from the cloud, the Volume ID field on the snapshots page will still have the original value, but still you can use the Snapshots page to remove unnecessary snapshots, as follows:

How to find and delete unused snapshots from AWS Console

From AWS CLI:

To get the list of snapshots not linked to any volume, do as follows:

ORPHANED_SNAPSHOT_IDS=$(comm -23 <(aws ec2 describe-snapshots --owner-ids $AWS-ACCOUNT-ID --query 'Snapshots[*].SnapshotId' --output text | tr '\t' '\n' | sort) <(aws ec2 describe-volumes --query 'Volumes[*].SnapshotId' --output text | tr '\t' '\n' | sort | uniq))

To get the list of snapshots not linked to any AMIs, do as follows:

ORPHANED_SNAPSHOT_IDS=$(comm -23 <(aws ec2 describe-snapshots --owner-ids $AWS_ACCOUNT_ID --query 'Snapshots[*].SnapshotId' --output text | tr '\t' '\n' | sort) <(aws ec2 describe-images --filters Name=state,Values=available --owners $AWS_ACCOUNT_ID --query "Images[*].BlockDeviceMappings[*].Ebs.SnapshotId" --output text | tr '\t' '\n' | sort | uniq))

Use regular shell loop to remove the snapshots for volumes and AMIs:

for snapshot_id in $ORPHANED_SNAPSHOT_IDS; do echo "aws ec2 delete-snapshot --snapshot-id $snapshot_id"; done

Conclusion

Dozens of AWS volume snapshots are typically created by a company engineering team on a daily basis. EBS snapshots have become a popular choice to backup and restore data on Amazon EC2. But some challenges may occur while deleting instances, and many companies continue to pay for them. 

The ways of identifying and deleting orphaned and unused snapshots, as described in the article, will help you avoid wastage, achieve optimization goals, reduce your cloud bill, and take the initial steps towards implementing a FinOps methodology in your company.

Free cloud cost optimization. Lifetime →  Sign up

Elastic IP addresses on Amazon EC2 are free of charge, but only if the following rules are applied. Get more details about the rules of using Elastic IP addresses on Amazon EC2, and start saving your company’s cloud budget → ‘How to release Elastic IPs on Amazon EC2.’

Enter your email to be notified about new and relevant content.

Thank you for joining us!

We hope you'll find it usefull

You can unsubscribe from these communications at any time. Privacy Policy

News & Reports

FinOps & Test Environment Management

A full description of OptScale as a FinOps and Test Environment Management platform to organize shared IT environment usage, optimize & forecast Kubernetes and cloud costs

From FinOps to proven cloud cost management & optimization strategies

This ebook covers the implementation of basic FinOps principles to shed light on alternative ways of conducting cloud cost optimization

Engage your engineers in FinOps and cloud cost saving

Discover how OptScale helps companies quickly increase FinOps adoption by engaging engineers in FinOps enablement and cloud cost savings