Skip to content
This repository was archived by the owner on Nov 20, 2022. It is now read-only.

An Amazon Web Services (AWS) stack that backs up instances on an interval, and purges the backup Amazon Machine Images (AMI) it creates after 7 days.

License

Notifications You must be signed in to change notification settings

sween/aws-instance-backup-ami-purge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gaze

made-with-terraform

Terraform AWS EC2 Instance Backup and AMI Purge

A Terraform plan that will deploy a set of resources that will...

...search for all instances having a tag with "Backup" or "backup" on it. As soon as we have the instances list, we loop through each instance and create an AMI of it. After creating the AMI it creates a "DeleteOn" tag on the AMI indicating when it will be deleted using the Retention value and another Lambda function will...

...delete (or de-register) that AMI.

This results in a repository of AMI's with a retention for 7 days.

Resources Created

This plan includes the creation of the following AWS Resources:

-- Lambda Function: Backup of Instances with the tag of "Backup"
-- Lambda Function: Deletion of Created AMI's from Backup with a DeleteOn of the specified time duration in days.
-- ExecutionRole: Shared by both functions.
-- Shceduled Rule: Trigger for Backup function.
-- Scheduled Rule: Trigger for purge function.
-- Lambda Permissions(2): Permission to Invoke Respective Lamba Functions.

Usage

# Terraform shampoo
terraform init
terraform plan
terraform apply

Legacy

There is also a Cloudformation Version of this included in case you dont Terraform.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Author

Contains stolen gists glued together with Stack Overflow and HCL by Ron Sweeney ron@basenube.com

License

License
MIT

About

An Amazon Web Services (AWS) stack that backs up instances on an interval, and purges the backup Amazon Machine Images (AMI) it creates after 7 days.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published