Skip to content

Commit 6ee846d

Browse files
committed
feature/PI-407-immutable_backups Add dynamo backup plan config and remove restore plans
1 parent a43a5c1 commit 6ee846d

File tree

4 files changed

+54
-26
lines changed

4 files changed

+54
-26
lines changed
Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
resource "awscc_backup_restore_testing_plan" "backup_restore_testing_plan" {
2-
restore_testing_plan_name = "backup_restore_testing_plan"
3-
schedule_expression = var.restore_testing_plan_scheduled_expression
4-
start_window_hours = var.restore_testing_plan_start_window
5-
recovery_point_selection = {
6-
algorithm = var.restore_testing_plan_algorithm
7-
include_vaults = [aws_backup_vault.main.arn]
8-
recovery_point_types = var.restore_testing_plan_recovery_point_types
9-
selection_window_days = var.restore_testing_plan_selection_window_days
10-
}
11-
}
1+
# resource "awscc_backup_restore_testing_plan" "backup_restore_testing_plan" {
2+
# restore_testing_plan_name = "backup_restore_testing_plan"
3+
# schedule_expression = var.restore_testing_plan_scheduled_expression
4+
# start_window_hours = var.restore_testing_plan_start_window
5+
# recovery_point_selection = {
6+
# algorithm = var.restore_testing_plan_algorithm
7+
# include_vaults = [aws_backup_vault.main.arn]
8+
# recovery_point_types = var.restore_testing_plan_recovery_point_types
9+
# selection_window_days = var.restore_testing_plan_selection_window_days
10+
# }
11+
# }
1212

13-
resource "awscc_backup_restore_testing_selection" "backup_restore_testing_selection_dynamodb" {
14-
count = var.backup_plan_config_dynamodb.enable ? 1 : 0
15-
iam_role_arn = aws_iam_role.backup.arn
16-
protected_resource_type = "DynamoDB"
17-
restore_testing_plan_name = awscc_backup_restore_testing_plan.backup_restore_testing_plan.restore_testing_plan_name
18-
restore_testing_selection_name = "backup_restore_testing_selection_dynamodb"
19-
protected_resource_arns = ["*"]
20-
protected_resource_conditions = {
21-
string_equals = [{
22-
key = "aws:ResourceTag/${var.backup_plan_config_dynamodb.selection_tag}"
23-
value = "True"
24-
}]
25-
}
26-
}
13+
# resource "awscc_backup_restore_testing_selection" "backup_restore_testing_selection_dynamodb" {
14+
# count = var.backup_plan_config_dynamodb.enable ? 1 : 0
15+
# iam_role_arn = aws_iam_role.backup.arn
16+
# protected_resource_type = "DynamoDB"
17+
# restore_testing_plan_name = awscc_backup_restore_testing_plan.backup_restore_testing_plan.restore_testing_plan_name
18+
# restore_testing_selection_name = "backup_restore_testing_selection_dynamodb"
19+
# protected_resource_conditions = {
20+
# string_equals = [{
21+
# key = "aws:ResourceTag/${var.backup_plan_config_dynamodb.selection_tag}"
22+
# value = "True"
23+
# }]
24+
# }
25+
# }

infrastructure/terraform/modules/aws-backup-source/iam.tf

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ resource "aws_iam_role_policy_attachment" "s3_backup" {
3636
role = aws_iam_role.backup.name
3737
}
3838

39+
resource "aws_iam_role_policy_attachment" "backup_full_access" {
40+
policy_arn = "arn:aws:iam::aws:policy/AWSBackupFullAccess"
41+
role = aws_iam_role.backup.name
42+
}
43+
3944

4045
resource "aws_iam_policy" "restore_testing_selection_permissions" {
4146
name = "${local.resource_name_prefix}-source-account-backup-permissions"
@@ -49,7 +54,7 @@ resource "aws_iam_policy" "restore_testing_selection_permissions" {
4954
"cloudformation:*"
5055
],
5156
Resource = "*"
52-
}
57+
},
5358
]
5459
})
5560
}

infrastructure/terraform/per_account/dev/aws-backups.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,24 @@ module "source" {
102102
],
103103
"selection_tag" : "NHSE-Enable-Backup"
104104
}
105+
106+
backup_plan_config_dynamodb = {
107+
"enable" : true,
108+
"compliance_resource_types" : [
109+
"DynamoDB"
110+
],
111+
"rules" : [
112+
{
113+
"copy_action" : {
114+
"delete_after" : 4
115+
},
116+
"lifecycle" : {
117+
"delete_after" : 2
118+
},
119+
"name" : "daily_kept_for_2_days",
120+
"schedule" : "cron(0 0 * * ? *)"
121+
}
122+
],
123+
"selection_tag" : "NHSE-Enable-Backup"
124+
}
105125
}

infrastructure/terraform/per_account/dev/terraform.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,9 @@ terraform {
2525
source = "hashicorp/local"
2626
version = "~> 2.0"
2727
}
28+
awscc = {
29+
source = "hashicorp/awscc"
30+
version = "~> 1.32.0"
31+
}
2832
}
2933
}

0 commit comments

Comments
 (0)