Skip to main content
Module Server 0.16.1Last updated in version 0.15.10

EC2 Backup Module

View Source Release Notes

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

main.tf

# ------------------------------------------------------------------------------------------------------
# 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"]

}


Reference

Required

schedule_namestringrequired

The name of the data lifecyle management schedule

target_tagsmap(string)required

A map of tag keys and their values. Any EBS volumes tagged with any of these tags will be targeted for snapshots.

Optional

backup_enabledbooloptional

Set to true to enable backups. Set to false to disable backups

true
copy_tagsbooloptional

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

true
dlm_role_namestringoptional

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

null
intervalnumberoptional

How often this lifecycle policy should be evaluated. Units for this value are defined in interval_unit

24
interval_unitstringoptional

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

"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_addmap(string)optional

This tag will be added to the Snapshot taken by the data lifecycle manager

{}
timeslist(string)optional

A list of times in 24 hour clock format that sets when the lifecyle policy should be evaluated. Max of 1.

[ "23:45" ]