
USE-CASE :: Cost optimisation
This use case if used to check if you have any stale Snapshot in your AWS account and delete it . So that Python script checks the which volume and snapshot is present and then, if that snapshot is attached to any volume , if that then Lambda function delete that
Link for the python script
https://github.com/ApurvDevops/AWS/tree/master/cost-optimzation
Steps
- Create EC2 Instance
Associated Volume
- Take a Snapshot of the Volume associated with EC2 Instance
- Create a Lambda Function and add the required IAM Roles ( DescribeInstance, DescribeSnapshot, Deletesnapshot,DescribeVolume )
Failed because of Insufficient permission
Added the Policies as mentioned on above steps DescribeInstance, DescribeSnapshot, Deletesnapshot,DescribeVolume. Also Increase the Timeout to 10 secconds default timeout is 3 sec
Increased it to 10 Seconds.
Lambda Function ran successfully, but snapshot is still there
- Delete the EC2 Instance and then run the lambda function again.
Only Snapshot is there, now runt the function again manually
5) Extended Trails
You can even try to create a Volume create a snapshot of this, and try to run the function again. and again run the Lambda function, and see the result
Thanks for reading, if you reached till here, please try to implement this simplest lab , cheers !!!
Comments
Join the discussionNo comments yet. Be the first to comment.
aws-cloud
Welcome to my dedicated AWS writing domain. Here, I break down cloud architecture, serverless systems, DevOps best practices, and practical AWS tutorials. This series centralizes all my cloud infrastructure deep dives into one unified space to help you build scalable and secure cloud applications.




