Skip to content

Repository files navigation

AWS Cloud Cost Optimization - Identifying Stale Resources Identifying Stale EBS Snapshots In this example, create a Lambda function that identifies EBS snapshots that are no longer associated with any active EC2 instance and deletes them to save on storage costs.

Description: The Lambda function fetches all EBS snapshots owned by the same account ('self') and also retrieves a list of active EC2 instances (running and stopped). For each snapshot, it checks if the associated volume (if exists) is not associated with any active instance. If it finds a stale snapshot, it deletes it, effectively optimizing storage costs.

1.Launch a ec2- instance image

2.Volume also gets created with ec2-instance image

3.Create a snapshot for that volume id image

4.Create a Lambda function image

5.Paste the code in Code section image

  1. Click on Test to create a test event and save image

7.Create policy to add permission image

8.permissions to add to the policy 1 describe snapshots 2 delete snapshot 3 describe instances 4 describe volumes

9.Terminate the ec2-insance and Test the code it will delete the stale snappshot.

About

This is AWS cost optimisation project which will delete the stale ebs snapshots.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages