A Terraform module to automate the taking of backup snapshots.
Include this repository as a module in your existing terraform code:
module "ebsnapshot" {
source = "JamesWoolfenden/ebssnap/aws"
version = "0.2.9"
common_tags = var.common_tags
snapshot_name = local.snapshot_name
cron_expression = var.cron_expression
regions = var.regions
}
Creates a lambda and cloudwatch event to look for any instances that have the specified tag and then takes a snapshot of that volume. This is a heavily modified version of this module: https://github.com/kgorskowski/ebs_bckup
Set up your Terraform tf.vars file to look something like:
common_tags = {
application = "terraform"
module = "auto-ebs-snapshot"
environment = "develop"
}
EC2_INSTANCE_TAG = "Backup"
RETENTION_DAYS = 10
cron_expression = "45 1 * * ? *"
regions = ["eu-west-1","eu-west-2","eu-west-3"]
No requirements.
Name | Version |
---|---|
archive | n/a |
aws | n/a |
random | n/a |
template | n/a |
No modules.
Name | Type |
---|---|
aws_cloudwatch_event_rule.ebsbackuptimer | resource |
aws_cloudwatch_event_target.runebsbackuplambda | resource |
aws_iam_role.ebsbackuplambda | resource |
aws_iam_role_policy.ebsbackuplambda | resource |
aws_lambda_function.ebsbackup | resource |
aws_lambda_permission.allow_cloudwatch_to_call | resource |
random_string.label | resource |
template_dir.vars | resource |
archive_file.lambda_zip | data source |
aws_iam_policy_document.ebsbackuplambda | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
EC2_INSTANCE_TAG | Tag to identify the EC2 target instances of the Lambda Function | string |
"Backup" |
no |
RETENTION_DAYS | Numbers of Days that the EBS Snapshots will be stored (INT) | string |
5 |
no |
common_tags | Implements the common tags scheme | map(any) |
n/a | yes |
cron_expression | Cron expression for firing up the Lambda Function | string |
n/a | yes |
regions | Which Regions to apply the snapshots too | list(any) |
n/a | yes |
runtime | n/a | string |
"python2.7" |
no |
snapshot_name | The name of the snapshot | string |
n/a | yes |
timeout | Lambda Timeout in seconds | number |
60 |
no |
tracing_mode | Xray tracing mode | string |
"Active" |
no |
Name | Description |
---|---|
lambda | n/a |
role | n/a |
Check out these related projects.
- terraform-aws-s3 - S3 buckets