From 64ced13efdae688f41fa01788ea8dcc830db40f4 Mon Sep 17 00:00:00 2001 From: Paul Montero Date: Mon, 15 Jul 2019 01:06:24 -0500 Subject: [PATCH] Add DLM module to single-node-asg #214 --- modules/single-node-asg/main.tf | 14 +++++++++++ modules/single-node-asg/variables.tf | 37 ++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/modules/single-node-asg/main.tf b/modules/single-node-asg/main.tf index 34c25f50..7e746bd1 100644 --- a/modules/single-node-asg/main.tf +++ b/modules/single-node-asg/main.tf @@ -22,6 +22,7 @@ module "service-data" { encrypted = "${var.data_volume_encrypted}" kms_key_id = "${var.data_volume_kms_key_id}" snapshot_id = "${var.data_volume_snapshot_id}" + extra_tags = {"createSnapshot" = "${var.name_prefix}"} } module "server" { @@ -62,6 +63,19 @@ module "init-attach-ebs" { volume_id = "${module.service-data.volume_id}" } + module "dlm-policy" { + source = "../dlm-lifecycle-policy" + + name_prefix = "${var.name_prefix}" + dlm_description = "${var.dlm_description}" + ebs_target_tags = {"createSnapshot" = "${var.name_prefix}"} + create_dlm_iam_role = "${var.dlm_create_dlm_iam_role}" + schedule_create_interval = "${var.dlm_schedule_create_interval}" + schedule_create_time = "${var.dlm_schedule_create_time}" + schedule_retain_rule = "${var.dlm_schedule_retain_rule}" + schedule_tags_to_add = "${merge(map("Name", "${var.name_prefix}-${name-sufix}-dlm", "SnapshotCreator", "DLM lifecycle"))}" + } + # Data source for AWS subnet data "aws_subnet" "server-subnet" { id = "${var.subnet_id}" diff --git a/modules/single-node-asg/variables.tf b/modules/single-node-asg/variables.tf index f5fdc72e..42a847ce 100644 --- a/modules/single-node-asg/variables.tf +++ b/modules/single-node-asg/variables.tf @@ -115,3 +115,40 @@ variable "load_balancers" { description = "The list of load balancers names to pass to the ASG module" type = "list" } + +## DLM variables +variable "dlm_create_dlm_iam_role" { + description = "Creates DLM IAm role and permissions to create snapshots, the role can be create one time pero AWS account" + default = "false" +} + +variable "dml_description" { + description = "DLM lifecycle policy description" + default = "DLM lifecycle policy" +} + +variable "dlm_ebs_target_tags" { + description = "Tags to filter the volume that we want to take the snapshot." + default = {} +} + +variable "dlm_schedule_create_interval" { + description = "Snapshots schedule interval" + default = 24 +} + +variable "dlm_schedule_create_time" { + description = "Time at which the snapshot will take." + type = "list" + default = ["23:45"] +} + +variable "dlm_schedule_retain_rule" { + description = "Snapshots schedule retein rule, how many snapshots are retaining" + default = 14 +} + +variable "dlm_schedule_copy_tags" { + description = "Copy all user-defined tags on a source volume to snapshots of the volume created by this policy." + default = false +}