How to Identify and Eliminate Orphaned Snapshots

Hidden costs on your AWS bill: How to identify and eliminate orphaned snapshots

By John Rochdale
ITFM Consultant

Managing costs in the cloud can be challenging, especially when dealing with large and complex environments like AWS. As a FinOps professional with a background in cloud engineering, I’ve seen firsthand how overlooked areas like orphaned snapshots can contribute to unnecessary expenses. A few years ago, orphan snapshots were something I had overlooked in my own cloud management practices. Since then, I’ve come to understand the significant savings that can be achieved by deleting these unused backups. Here’s a actionable step-by-step guide on how to identify and eliminate orphaned snapshots to reduce your AWS bill.

What are orphaned snapshots?

Orphaned snapshots are backups of your Amazon Elastic Block Store (EBS) volumes that are no longer attached to any running instances. These snapshots can accumulate over time, leading to unnecessary storage costs. While each snapshot might seem small in isolation, together they can add up to a significant expense.

Cut costs and keep your cloud environment organized

To eliminate orphaned snapshots is crucial for several reasons:

Step-by-step guide

Step 1: Inventory your snapshots

Tools Required:

Procedure:

aws ec2 describe-snapshots –owner-ids self

Step 2: Identify orphaned snapshots

Tools Required:

Procedure:

import boto3

ec2 = boto3.client('ec2')

snapshots = ec2.describe_snapshots(OwnerIds=['self'])['Snapshots']
volumes = ec2.describe_volumes()['Volumes']

volume_ids = [volume['VolumeId'] for volume in volumes]

orphaned_snapshots = [snapshot for snapshot in snapshots if snapshot['VolumeId'] not in volume_ids]

for orphaned_snapshot in orphaned_snapshots:
    print(f"Orphaned Snapshot ID: {orphaned_snapshot['SnapshotId']}")

Step 3: Evaluate snapshots for deletion

Considerations:

Step 4: Delete orphaned snapshots

Procedure:

aws ec2 delete-snapshot –snapshot-id

Example in Python using Boto3:

for orphaned_snapshot in orphaned_snapshots:
    ec2.delete_snapshot(SnapshotId=orphaned_snapshot['SnapshotId'])
    print(f"Deleted Snapshot ID: {orphaned_snapshot['SnapshotId']}")

Step 5: Automate the process

Tools required:

Procedure:

  1. Create an AWS Lambda Function:
    • Write a Lambda function to identify and delete orphaned snapshots periodically.
  2. Schedule with CloudWatch events:
    • Create a CloudWatch Event to trigger the Lambda function at a regular interval (e.g., daily, weekly).

Step 6: Implement continuous monitoring

Tools Required:

Procedure:

  1. Cloud management tools:
    • Use tools like Zesty or Torque to continuously monitor and report on orphaned snapshots.
  2. Custom alerts:
    • Set up custom alerts to notify when new orphaned snapshots are identified.

How to estimate the potential savings

In order to obtain a rough estimate of how much you can save from removing orphaned snapshots, you’ll need to consider the following factors:

  1. Number of orphaned snapshots:
    • Identify how many orphaned snapshots exist in your environment.
  2. Size of each snapshot:
    • Determine the size (in GB) of each snapshot.
  3. Cost per GB:
    • Find out the storage cost per GB for your cloud provider (e.g., AWS charges $0.05 per GB per month for EBS snapshots).
  4. Duration:
    • Estimate how long these snapshots have been orphaned and accumulating costs.

Example calculation

Step 1: Identify number of orphaned snapshots

Let’s say you have identified 100 orphaned snapshots.

Step 2: Determine the size of each snapshot

Assume the average size of each snapshot is 100 GB.

Step 3: Find cost per GB

AWS charges $0.05 per GB per month for EBS snapshots.

Step 4: Estimate the duration

Assume the snapshots have been orphaned for 6 months.

Calculation

  1. Total storage used by orphaned snapshots:

Total Storage = Number of Snapshots × Average Size of Each Snapshot

Total Storage = 100 × 100 GB = 10,000 GB

  1. Monthly cost:

Monthly Cost = Total Storage × Cost per GB

Monthly Cost = 10,000 GB × $0.05 per GB = $500

  1. Total cost over 6 months:

Total Cost = Monthly Cost × Duration (in months)

Total Cost = $500 × 6 = $3,000

Savings

By identifying and removing these 100 orphaned snapshots, you could save approximately $3,000 over a 6-month period.

Keep your AWS costs under control

By identifying and eliminating orphaned snapshots, you can significantly reduce your AWS bill and maintain a more efficient cloud environment. Regularly auditing your AWS resources and automating snapshot management are key practices to ensure ongoing cost optimization and operational efficiency. Start implementing these steps today to keep your AWS costs under control.