Skip to content

samidha1-1/aws-ebs-cost-optimization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

AWS EBS Cost Optimization using Lambda & Boto3

In screenshots ec2-runnings.png contains the before lambda function trigggering the instance and in ec2-stopped.png contains after lambda triggering the instance .

Project Overview

This project focuses on optimizing AWS EBS storage costs by automatically identifying and deleting unused/stale EBS snapshots.The solution uses AWS Lambda, Boto3 (Python SDK). To perform automated cleanup .

Problem Statement

In AWS environments

  • In AWS acc EBS often remain even after volumes or EC2 isntance are deleted
  • These stale snapshots ofter incur storage costs

Goal: Automatically detect and delete unused EBS snapshots to reduce AWS costs.

Technologies & Services Used

  • AWS Lambda – Serverless execution of cleanup logic
  • Amazon EC2 – Source of EBS volumes and snapshots
  • Amazon EBS – Block storage snapshots
  • AWS IAM – Permissions for secure access
  • Python (Boto3) – AWS SDK for automation

Lambda Logic (High-Level)

  • Collect running EC2 instance IDs
  • Iterate through all snapshots
  • Validate snapshot → volume → instance relationship
  • Safely delete unused/stale snapshots
  • Handle exceptions like deleted volumes

Architecture

  • Lambda function runs manual or via schedule
  • Lambda fetches all running EC2 instances
  • Identifies active instance IDs
  • Fetches all EBS snapshots owned by the account
  • Checks: -Snapshot without volume -Snapshot linked to deleted volume -Snapshot linked to unused volume
  • Deletes eligible snapshots
  • Logs actions to CloudWatch

How to Run / Test

  • Create an unused EBS volume
  • Create a snapshot of that volume
  • Delete the volume
  • Invoke the Lambda function
  • Verify snapshot deletion via CloudWatch logs

Author

Samidha Nitin Wani Cloud Engineer / DevOps Engineer

Key Takeaway

This project demonstrates real-world AWS automation, cost-optimization strategies, and production-ready Lambda development, making it highly suitable for cloud-focused roles.

About

An AWS Lambda–based automation to optimize cloud costs by removing unused EBS snapshots.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages