-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathmain.tf
More file actions
131 lines (126 loc) · 3.23 KB
/
main.tf
File metadata and controls
131 lines (126 loc) · 3.23 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# AWS SNS Topic
resource "aws_sns_topic" "backup_vault_notifications" {
name = "backup-vault-events"
}
# AWS Backup
module "aws_backup_example" {
source = "../.."
# Vault
vault_name = "vault-1"
# Vault lock configuration
min_retention_days = 7
max_retention_days = 120
# Multiple plans
plans = {
# First plan for daily backups
daily = {
name = "daily-backup-plan"
rules = [
{
name = "daily-rule"
schedule = "cron(0 12 * * ? *)"
start_window = 120
completion_window = 360
lifecycle = {
delete_after = 30
}
recovery_point_tags = {
Environment = "prod"
Frequency = "daily"
}
}
]
selections = {
prod_databases = {
resources = [
"arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table1"
]
selection_tags = [
{
type = "STRINGEQUALS"
key = "Environment"
value = "prod"
}
]
}
}
},
# Second plan for weekly backups
weekly = {
name = "weekly-backup-plan"
rules = [
{
name = "weekly-rule"
schedule = "cron(0 0 ? * 1 *)" # Run every Sunday at midnight
start_window = 120
completion_window = 480
lifecycle = {
cold_storage_after = 30
delete_after = 120
}
recovery_point_tags = {
Environment = "prod"
Frequency = "weekly"
}
}
]
selections = {
all_databases = {
resources = [
"arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table1",
"arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table2"
]
}
}
},
# Third plan for monthly backups with cross-region copy
monthly = {
name = "monthly-backup-plan"
rules = [
{
name = "monthly-rule"
schedule = "cron(0 0 1 * ? *)" # Run at midnight on the first day of every month
start_window = 120
completion_window = 720
lifecycle = {
cold_storage_after = 90
delete_after = 365
}
copy_actions = [
{
destination_vault_arn = "arn:aws:backup:us-west-2:123456789101:backup-vault:Default"
lifecycle = {
cold_storage_after = 90
delete_after = 365
}
}
]
recovery_point_tags = {
Environment = "prod"
Frequency = "monthly"
}
}
]
selections = {
critical_databases = {
resources = [
"arn:aws:dynamodb:us-east-1:123456789101:table/mydynamodb-table1"
]
selection_tags = [
{
type = "STRINGEQUALS"
key = "Criticality"
value = "high"
}
]
}
}
}
}
# Tags
tags = {
Owner = "backup team"
Environment = "prod"
Terraform = true
}
}