From 3199a0f1ebc1da32228040f5fe5ba7352270f192 Mon Sep 17 00:00:00 2001 From: Paul Montero Date: Thu, 16 May 2019 17:22:27 -0500 Subject: [PATCH] Module to enable DML lifecycle policies --- modules/dlm-lifecycle-policy/README.md | 26 ++++++++++++ modules/dlm-lifecycle-policy/iam.tf | 51 +++++++++++++++++++++++ modules/dlm-lifecycle-policy/main.tf | 46 ++++++++++++++++++++ modules/dlm-lifecycle-policy/variables.tf | 51 +++++++++++++++++++++++ 4 files changed, 174 insertions(+) create mode 100644 modules/dlm-lifecycle-policy/README.md create mode 100644 modules/dlm-lifecycle-policy/iam.tf create mode 100644 modules/dlm-lifecycle-policy/main.tf create mode 100644 modules/dlm-lifecycle-policy/variables.tf diff --git a/modules/dlm-lifecycle-policy/README.md b/modules/dlm-lifecycle-policy/README.md new file mode 100644 index 00000000..defcbf9b --- /dev/null +++ b/modules/dlm-lifecycle-policy/README.md @@ -0,0 +1,26 @@ +## Data Lifecycle Manager (DLM) lifecycle policy for managing snapshots + +This module creates an IAM role and a policy that manage the creation of EBS snapshots, Data Lifecycle Manager policy let you create snapshots according to the schedule that you choose. + +### Example how to use + +Define the module in your terraform project: +``` +variable "ebs_target_tags" { + description = "EBS name/tag to query" + default = "myebstagname" +} + +Define variables +... + +module "ebs-backup-policy" { + source = "git::https://github.com/fpco/terraform-aws-foundation//modules/dlm-lifecycle-policy" + + dml_description = "${var.dml_description}" + ebs_target_tags = "${(map("Name", "${var.ebs_target_tags}")}" + schedule_interval = "${var.schedule_interval}" + schedule_times = "${var.schedule_interval_times}" + schedule_retain_rule = "${var.schedule_retain_rule}" +} +``` diff --git a/modules/dlm-lifecycle-policy/iam.tf b/modules/dlm-lifecycle-policy/iam.tf new file mode 100644 index 00000000..12204ce8 --- /dev/null +++ b/modules/dlm-lifecycle-policy/iam.tf @@ -0,0 +1,51 @@ +# Create the iam role +resource "aws_iam_role" "dlm_lifecycle_role" { + name = "dlm-lifecycle-role" + + assume_role_policy = <