Skip to content

Commit 4c9cde6

Browse files
committed
[NRL-853] WIP - Switch copy_action to list, still more to do on that
1 parent 001cf2f commit 4c9cde6

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

terraform/account-wide-infrastructure/dev/aws-backup.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ module "source" {
112112
"enable" : true,
113113
"rules" : [
114114
{
115-
"copy_action" : {
115+
"copy_action" : [{
116116
"delete_after" : 4
117-
},
117+
}],
118118
"lifecycle" : {
119119
"delete_after" : 2
120120
},
@@ -134,9 +134,9 @@ module "source" {
134134
{
135135
"name" : "daily",
136136
"schedule" : "cron(0 0 * * ? *)",
137-
"copy_action" : {
137+
"copy_action" : [{
138138
"delete_after" : 4
139-
},
139+
}],
140140

141141
"lifecycle" : {
142142
"delete_after" : 2
@@ -145,10 +145,10 @@ module "source" {
145145
{
146146
"name" : "monthly"
147147
"schedule" : "cron(30 0 * * 4#1)" # first Thursday each month from 00:30
148-
"copy_action" : {
148+
"copy_action" : [{
149149
"cold_storage_after" : 3,
150150
"delete_after" : 100 # ensures there will always be min 3
151-
},
151+
}],
152152
"lifecycle" : {
153153
"delete_after" : 2
154154
}
@@ -157,10 +157,10 @@ module "source" {
157157
{
158158
"name" : "weekly" # overlaps with monthly
159159
"schedule" : "cron(30 0 * * 4)" # every Thursday from 00:30 to precede releases
160-
"copy_action" : {
160+
"copy_action" : [{
161161
"cold_storage_after" : 14 # ensures 2 warm including one from previous release
162162
"delete_after" : 100
163-
},
163+
}],
164164
"lifecycle" : {
165165
"delete_after" : 2
166166
}

terraform/account-wide-infrastructure/modules/backup-source/backup_plan.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ resource "aws_backup_plan" "default" {
1717
cold_storage_after = rule.value.lifecycle.cold_storage_after != null ? rule.value.lifecycle.cold_storage_after : null
1818
}
1919
dynamic "copy_action" {
20-
for_each = rule.value.copy_action != null ? rule.value.copy_action : {}
20+
for_each = rule.value.copy_action
2121
content {
2222
lifecycle {
23-
delete_after = copy_action.value.lifecycle.delete_after
24-
cold_storage_after = copy_action.value.lifecycle.cold_storage_after
23+
delete_after = copy_action.value.delete_after
24+
cold_storage_after = copy_action.value.cold_storage_after != null ? copy_action.value.cold_storage_after : null
2525
}
2626
destination_vault_arn = var.backup_copy_vault_arn
2727
}

terraform/account-wide-infrastructure/modules/backup-source/variables.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,18 @@ variable "backup_plan_config" {
7878
enable = bool
7979
selection_tag = string
8080
compliance_resource_types = list(string)
81-
rules = list(object({
81+
rules = optional(list(object({
8282
name = string
8383
schedule = string
8484
enable_continuous_backup = optional(bool)
8585
lifecycle = object({
8686
delete_after = optional(number)
8787
cold_storage_after = optional(number)
8888
})
89-
copy_action = optional(object({
89+
copy_action = optional(list(object({
9090
delete_after = optional(number)
91-
}))
92-
}))
91+
})))
92+
})))
9393
})
9494
}
9595
variable "backup_plan_config_dynamodb" {
@@ -106,10 +106,10 @@ variable "backup_plan_config_dynamodb" {
106106
delete_after = number
107107
cold_storage_after = optional(number)
108108
})
109-
copy_action = optional(object({
109+
copy_action = optional(list(object({
110110
delete_after = optional(number)
111111
cold_storage_after = optional(number)
112-
}))
112+
})))
113113
})))
114114
})
115115

0 commit comments

Comments
 (0)