Skip to content

Commit

Permalink
Use built in AWS snapshots to backup production couchdb2 volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyroberts committed Feb 13, 2019
1 parent 3d45c20 commit fd7757f
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/commcare_cloud/commands/terraform/templates/commcarehq.tf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,44 @@ locals {
}
}


data "aws_iam_role" "data_lifecycle_role" {
name = "AWSDataLifecycleManagerDefaultRole"
}

resource "aws_dlm_lifecycle_policy" "data_volume_backups" {
description = "Data Volume Backup Policy"
execution_role_arn = "${data.aws_iam_role.data_lifecycle_role.arn}"
state = "ENABLED"

policy_details {
resource_types = ["VOLUME"]

schedule {
name = "Default Schedule"

create_rule {
interval = 24
interval_unit = "HOURS"
times = ["22:00"]
}

retain_rule {
count = 7
}

tags_to_add = {
VolumeType = "backup"
}
}

target_tags = {
Group = "couchdb2"
VolumeType = "data"
}
}
}

{% for server in servers + proxy_servers %}
module "server__{{ server.server_name }}" {
source = "./modules/server"
Expand Down
3 changes: 2 additions & 1 deletion src/commcare_cloud/terraform/modules/server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ resource "aws_ebs_volume" "ebs_volume" {
type = "${var.secondary_volume_type}"

tags {
Name = "vol-${var.server_name}"
Name = "data-vol-${var.server_name}"
ServerName = "${var.server_name}"
Environment = "${var.environment}"
Group = "${var.group_tag}"
VolumeType = "data"
}
}

Expand Down

0 comments on commit fd7757f

Please sign in to comment.