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.
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.
# Terraform shampoo
terraform init
terraform plan
terraform apply
There is also a Cloudformation Version of this included in case you dont Terraform.
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.
Contains stolen gists glued together with Stack Overflow and HCL by Ron Sweeney ron@basenube.com