Skip to content

Commit

Permalink
Add DLM module to single-node-asg fpco#214
Browse files Browse the repository at this point in the history
  • Loading branch information
lpaulmp committed Jul 15, 2019
1 parent 7e600e7 commit 64ced13
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
14 changes: 14 additions & 0 deletions modules/single-node-asg/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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}"
Expand Down
37 changes: 37 additions & 0 deletions modules/single-node-asg/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 64ced13

Please sign in to comment.