Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pattern submission: Retain Expired AMI and its Snapshot with AWS Lambda and Amazon EC2 Recycle Bin #2464

Open
Divya-Vijendra-Girase opened this issue Sep 2, 2024 · 0 comments

Comments

@Divya-Vijendra-Girase
Copy link

Divya-Vijendra-Girase commented Sep 2, 2024

To submit a template to the Serverless Patterns Collection, submit an issue with the following information.

Overview
In this pattern an Amazon EventBridge trigger AWS Lambda function to deregister AMI, delete the associated snapshot and move them to Recycle Bin for retention.

Language
Terraform for Infrastructure as Code
Python for Lambda function

Services from/to
Amazon EventBridge to Lambda to Amazon Recycle Bin

Description
In this pattern an Amazon EventBridge triggers AWS Lambda function to deregister AMI, delete the associated snapshot and move them to Recycle Bin for retention.

The template creates all the necessary resources including an Amazon EventBridge Rule that triggers the AWS Lambda function once every day. Additionally, Recycle Bin rules for AMI and EBS Snapshots are created to retain deleted resources matching the resources for a retention period.

AWS Lambda function automates the expiration of Amazon Machine Images (AMIs) moving the AMIs and its associated snapshot to Recycle Bin. The Recycle Bin is a feature in Amazon Elastic Compute Cloud (EC2) that allows you to retain AMIs that you have deregistered for a specified retention period, providing an opportunity to recover them if needed. To recover the deleted AMI, its associated snapshot should be recovered first. The lambda function also adds corresponding tags to both, the AMI and the EBS Snapshot before moving them to Recycle Bin for recovery.

Deployment commands

terraform init
terraform plan
terraform apply

GitHub PR
#2463

Payload example
NA

Author Bio
Name: Divya Vijendra Girase
LinkedIn: Connect on LinkedIn
Description: AWS Cloud Infrastructure Architect and a Serverless Enthusiast.

@Divya-Vijendra-Girase Divya-Vijendra-Girase changed the title New pattern submission New pattern submission: Retain Expired AMI and its Snapshot with AWS Lambda and Amazon EC2 Recycle Bin Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant