-
Notifications
You must be signed in to change notification settings - Fork 2
/
ebs-snapshot.tf
91 lines (70 loc) · 1.79 KB
/
ebs-snapshot.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
resource "aws_iam_role" "dlm" {
name = "${module.generator.prefix}-dlm"
description = "${module.generator.prefix} dlm role"
assume_role_policy = file("${path.module}/templates/roles/dlm_role.pol.tpl")
tags = merge(
{
"Name" = "${module.generator.prefix}-dlm"
},
module.generator.common_tags
)
}
resource "aws_iam_role_policy" "dlm" {
name = "${terraform.workspace}-dlm"
role = aws_iam_role.dlm.id
policy = file("${path.module}/templates/policies/dlm_policy.pol.tpl")
}
resource "aws_dlm_lifecycle_policy" "space07" {
count = local.is_prod_envs
description = "Make snapshots of space07 LVM volumes"
execution_role_arn = aws_iam_role.dlm.arn
state = "ENABLED"
policy_details {
resource_types = ["VOLUME"]
schedule {
name = "3 days of daily snapshots"
create_rule {
interval = 24
interval_unit = "HOURS"
times = ["02:00"]
}
retain_rule {
count = 3
}
tags_to_add = {
SnapshotCreator = "DLM"
}
copy_tags = true
}
target_tags = {
Tenant = "space07"
}
}
}
resource "aws_dlm_lifecycle_policy" "fvm-archive" {
count = local.is_prod_envs
description = "Make snapshots of fvm-archive LVM volumes"
execution_role_arn = aws_iam_role.dlm.arn
state = "ENABLED"
policy_details {
resource_types = ["VOLUME"]
schedule {
name = "3 days of daily snapshots"
create_rule {
interval = 24
interval_unit = "HOURS"
times = ["02:00"]
}
retain_rule {
count = 3
}
tags_to_add = {
SnapshotCreator = "DLM"
}
copy_tags = true
}
target_tags = {
Tenant = "fvm-archive"
}
}
}