EC2 Backup Module
This module makes it easy to deploy a data lifecycle manager policy that will automatically create snapshots of EBS volumes whose tags match the target you configure. This is ideal for managing automatic backups of your EC2 instances' EBS volumes.
Sample Usage
- Terraform
- Terragrunt
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S EC2-BACKUP MODULE
# ------------------------------------------------------------------------------------------------------
module "ec_2_backup" {
source = "git::git@github.com:gruntwork-io/terraform-aws-server.git//modules/ec2-backup?ref=v0.16.1"
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# The name of the data lifecyle management schedule
schedule_name = <string>
# A map of tag keys and their values. Any EBS volumes tagged with any of these
# tags will be targeted for snapshots.
target_tags = <map(string)>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# Set to true to enable backups. Set to false to disable backups
backup_enabled = true
# Set this to true to have the tags present on the target volume at the time
# of backup to be copied to the resulting snapshot
copy_tags = true
# The name for the IAM role associated with the data lifecycle manager. If
# this variable is null, the default of dlm-lifecycle-role will be used
dlm_role_name = null
# How often this lifecycle policy should be evaluated. Units for this value
# are defined in var.interval_unit
interval = 24
# The measurement of time to use for the schedule's interval. Note that
# currently this value must be HOURS, as this is the only supported interval
# unit
interval_unit = "HOURS"
# How many snapshots to keep. Must be an integer between 1 and 1000
number_of_snapshots_to_retain = 14
# The ARN of the policy that is used to set the permissions boundary for the
# IAM role.
role_permissions_boundary = null
# This tag will be added to the Snapshot taken by the data lifecycle manager
tags_to_add = {}
# A list of times in 24 hour clock format that sets when the lifecyle policy
# should be evaluated. Max of 1.
times = ["23:45"]
}
# ------------------------------------------------------------------------------------------------------
# DEPLOY GRUNTWORK'S EC2-BACKUP MODULE
# ------------------------------------------------------------------------------------------------------
terraform {
source = "git::git@github.com:gruntwork-io/terraform-aws-server.git//modules/ec2-backup?ref=v0.16.1"
}
inputs = {
# ----------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# ----------------------------------------------------------------------------------------------------
# The name of the data lifecyle management schedule
schedule_name = <string>
# A map of tag keys and their values. Any EBS volumes tagged with any of these
# tags will be targeted for snapshots.
target_tags = <map(string)>
# ----------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# ----------------------------------------------------------------------------------------------------
# Set to true to enable backups. Set to false to disable backups
backup_enabled = true
# Set this to true to have the tags present on the target volume at the time
# of backup to be copied to the resulting snapshot
copy_tags = true
# The name for the IAM role associated with the data lifecycle manager. If
# this variable is null, the default of dlm-lifecycle-role will be used
dlm_role_name = null
# How often this lifecycle policy should be evaluated. Units for this value
# are defined in var.interval_unit
interval = 24
# The measurement of time to use for the schedule's interval. Note that
# currently this value must be HOURS, as this is the only supported interval
# unit
interval_unit = "HOURS"
# How many snapshots to keep. Must be an integer between 1 and 1000
number_of_snapshots_to_retain = 14
# The ARN of the policy that is used to set the permissions boundary for the
# IAM role.
role_permissions_boundary = null
# This tag will be added to the Snapshot taken by the data lifecycle manager
tags_to_add = {}
# A list of times in 24 hour clock format that sets when the lifecyle policy
# should be evaluated. Max of 1.
times = ["23:45"]
}
Reference
- Inputs
- Outputs
Required
schedule_name
stringThe name of the data lifecyle management schedule
target_tags
map(string)A map of tag keys and their values. Any EBS volumes tagged with any of these tags will be targeted for snapshots.
Optional
backup_enabled
boolSet to true to enable backups. Set to false to disable backups
true
copy_tags
boolSet this to true to have the tags present on the target volume at the time of backup to be copied to the resulting snapshot
true
dlm_role_name
stringThe name for the IAM role associated with the data lifecycle manager. If this variable is null, the default of dlm-lifecycle-role will be used
null
interval
numberHow often this lifecycle policy should be evaluated. Units for this value are defined in interval_unit
24
interval_unit
stringThe measurement of time to use for the schedule's interval. Note that currently this value must be HOURS, as this is the only supported interval unit
"HOURS"
How many snapshots to keep. Must be an integer between 1 and 1000
14
The ARN of the policy that is used to set the permissions boundary for the IAM role.
null
tags_to_add
map(string)This tag will be added to the Snapshot taken by the data lifecycle manager
{}
times
list(string)A list of times in 24 hour clock format that sets when the lifecyle policy should be evaluated. Max of 1.
[
"23:45"
]
The ARN of the data lifecycle manager policy
The ARN of the IAM role associated with the data lifecycle manager
The name of the IAM role associated with the data lifecycle manager