Skip to content

Commit f1b59a8

Browse files
CCM-7890 Backup Module Refactor
1 parent 35bc1ca commit f1b59a8

19 files changed

Lines changed: 87 additions & 32 deletions

infrastructure/modules/aws-backup-source/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See [terraform-aws-backup](https://github.com/NHSDigital/terraform-aws-backup.gi
1515
| <a name="input_backup_plan_config"></a> [backup\_plan\_config](#input\_backup\_plan\_config) | Configuration for backup plans | <pre>object({<br> selection_tag = string<br> compliance_resource_types = list(string)<br> rules = list(object({<br> name = string<br> schedule = string<br> enable_continuous_backup = optional(bool)<br> lifecycle = object({<br> delete_after = optional(number)<br> cold_storage_after = optional(number)<br> })<br> copy_action = optional(object({<br> delete_after = optional(number)<br> }))<br> }))<br> })</pre> | <pre>{<br> "compliance_resource_types": [<br> "S3"<br> ],<br> "rules": [<br> {<br> "copy_action": {<br> "delete_after": 365<br> },<br> "lifecycle": {<br> "delete_after": 35<br> },<br> "name": "daily_kept_5_weeks",<br> "schedule": "cron(0 0 * * ? *)"<br> },<br> {<br> "copy_action": {<br> "delete_after": 365<br> },<br> "lifecycle": {<br> "delete_after": 90<br> },<br> "name": "weekly_kept_3_months",<br> "schedule": "cron(0 1 ? * SUN *)"<br> },<br> {<br> "copy_action": {<br> "delete_after": 365<br> },<br> "lifecycle": {<br> "cold_storage_after": 30,<br> "delete_after": 2555<br> },<br> "name": "monthly_kept_7_years",<br> "schedule": "cron(0 2 1 * ? *)"<br> },<br> {<br> "copy_action": {<br> "delete_after": 365<br> },<br> "enable_continuous_backup": true,<br> "lifecycle": {<br> "delete_after": 35<br> },<br> "name": "point_in_time_recovery",<br> "schedule": "cron(0 5 * * ? *)"<br> }<br> ],<br> "selection_tag": "BackupLocal"<br>}</pre> | no |
1616
| <a name="input_backup_plan_config_dynamodb"></a> [backup\_plan\_config\_dynamodb](#input\_backup\_plan\_config\_dynamodb) | Configuration for backup plans with dynamodb | <pre>object({<br> enable = bool<br> selection_tag = string<br> compliance_resource_types = list(string)<br> rules = optional(list(object({<br> name = string<br> schedule = string<br> enable_continuous_backup = optional(bool)<br> lifecycle = object({<br> delete_after = number<br> cold_storage_after = optional(number)<br> })<br> copy_action = optional(object({<br> delete_after = optional(number)<br> }))<br> })))<br> })</pre> | <pre>{<br> "compliance_resource_types": [<br> "DynamoDB"<br> ],<br> "enable": true,<br> "rules": [<br> {<br> "copy_action": {<br> "delete_after": 365<br> },<br> "lifecycle": {<br> "delete_after": 35<br> },<br> "name": "dynamodb_daily_kept_5_weeks",<br> "schedule": "cron(0 0 * * ? *)"<br> },<br> {<br> "copy_action": {<br> "delete_after": 365<br> },<br> "lifecycle": {<br> "delete_after": 90<br> },<br> "name": "dynamodb_weekly_kept_3_months",<br> "schedule": "cron(0 1 ? * SUN *)"<br> },<br> {<br> "copy_action": {<br> "delete_after": 365<br> },<br> "lifecycle": {<br> "cold_storage_after": 30,<br> "delete_after": 2555<br> },<br> "name": "dynamodb_monthly_kept_7_years",<br> "schedule": "cron(0 2 1 * ? *)"<br> }<br> ],<br> "selection_tag": "BackupDynamoDB"<br>}</pre> | no |
1717
| <a name="input_notification_kms_key"></a> [bootstrap\_kms\_key\_arn](#input\_bootstrap\_kms\_key\_arn) | The ARN of the bootstrap KMS key used for encryption at rest of the SNS topic. | `string` | n/a | yes |
18-
| <a name="input_environment_name"></a> [environment\_name](#input\_environment\_name) | The name of the environment where AWS Backup is configured. | `string` | n/a | yes |
18+
| <a name="input_environment"></a> [environment\_name](#input\_environment\_name) | The name of the environment where AWS Backup is configured. | `string` | n/a | yes |
1919
| <a name="input_notifications_target_email_address"></a> [notifications\_target\_email\_address](#input\_notifications\_target\_email\_address) | The email address to which backup notifications will be sent via SNS. | `string` | `""` | no |
2020
| <a name="input_project_name"></a> [project\_name](#input\_project\_name) | The name of the project this relates to. | `string` | n/a | yes |
2121
| <a name="input_reports_bucket"></a> [reports\_bucket](#input\_reports\_bucket) | Bucket to drop backup reports into | `string` | n/a | yes |
@@ -33,7 +33,7 @@ See [terraform-aws-backup](https://github.com/NHSDigital/terraform-aws-backup.gi
3333
module "test_aws_backup" {
3434
source = "./modules/aws-backup"
3535
36-
environment_name = "environment_name"
36+
environment = "environment"
3737
notification_kms_key = kms_key[0].arn
3838
project_name = "testproject"
3939
reports_bucket = "compliance-reports"

infrastructure/modules/aws-backup-source/backup_framework_dynamodb.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ resource "aws_backup_framework" "dynamodb" {
22
count = var.backup_plan_config_dynamodb.enable ? 1 : 0
33

44
# must be underscores instead of dashes
5-
name = replace("${local.resource_name_prefix}-dynamodb-framework", "-", "_")
6-
description = "${var.project_name} DynamoDB Backup Framework"
5+
name = replace("${local.csi}-dynamodb-framework", "-", "_")
6+
description = "${var.project} DynamoDB Backup Framework"
77

88
# Evaluates if recovery points are encrypted.
99
control {
1010
name = "BACKUP_RECOVERY_POINT_ENCRYPTED"
1111

1212
scope {
1313
tags = {
14-
Environment = var.environment_name
14+
Environment = var.environment
1515
}
1616
}
1717
}
@@ -22,7 +22,7 @@ resource "aws_backup_framework" "dynamodb" {
2222

2323
scope {
2424
tags = {
25-
Environment = var.environment_name
25+
Environment = var.environment
2626
}
2727
}
2828

@@ -38,7 +38,7 @@ resource "aws_backup_framework" "dynamodb" {
3838

3939
scope {
4040
tags = {
41-
Environment = var.environment_name
41+
Environment = var.environment
4242
}
4343
}
4444

@@ -54,7 +54,7 @@ resource "aws_backup_framework" "dynamodb" {
5454

5555
scope {
5656
tags = {
57-
Environment = var.environment_name
57+
Environment = var.environment
5858
}
5959
}
6060

infrastructure/modules/aws-backup-source/backup_framework_s3.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ resource "aws_backup_framework" "s3" {
22
count = var.backup_plan_config_s3.enable ? 1 : 0
33

44
# must be underscores instead of dashes
5-
name = replace("${local.resource_name_prefix}-framework", "-", "_")
6-
description = "${var.project_name} Backup Framework"
5+
name = replace("${local.csi}-framework", "-", "_")
6+
description = "${var.project} Backup Framework"
77

88
# Evaluates if recovery points are encrypted.
99
control {
1010
name = "BACKUP_RECOVERY_POINT_ENCRYPTED"
1111

1212
scope {
1313
tags = {
14-
Environment = var.environment_name
14+
Environment = var.environment
1515
}
1616
}
1717
}
@@ -22,7 +22,7 @@ resource "aws_backup_framework" "s3" {
2222

2323
scope {
2424
tags = {
25-
Environment = var.environment_name
25+
Environment = var.environment
2626
}
2727
}
2828

@@ -38,7 +38,7 @@ resource "aws_backup_framework" "s3" {
3838

3939
scope {
4040
tags = {
41-
Environment = var.environment_name
41+
Environment = var.environment
4242
}
4343
}
4444

@@ -54,7 +54,7 @@ resource "aws_backup_framework" "s3" {
5454

5555
scope {
5656
tags = {
57-
Environment = var.environment_name
57+
Environment = var.environment
5858
}
5959
}
6060

infrastructure/modules/aws-backup-source/backup_plan_dynamodb.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
resource "aws_backup_plan" "dynamodb" {
33
count = var.backup_plan_config_dynamodb.enable ? 1 : 0
44

5-
name = "${local.resource_name_prefix}-dynamodb-plan"
5+
name = "${local.csi}-dynamodb"
66

77
dynamic "rule" {
88
for_each = var.backup_plan_config_dynamodb.rules

infrastructure/modules/aws-backup-source/backup_plan_s3.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "aws_backup_plan" "s3" {
22
count = var.backup_plan_config_s3.enable ? 1 : 0
33

4-
name = "${local.resource_name_prefix}-plan"
4+
name = "${local.csi}-s3"
55

66
dynamic "rule" {
77
for_each = var.backup_plan_config_s3.rules

infrastructure/modules/aws-backup-source/backup_report_plan_backup_jobs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Create the reports
22
resource "aws_backup_report_plan" "backup_jobs" {
3-
name = "backup_jobs"
3+
name = "${local.csi_underscore}_backup_jobs"
44
description = "Report for showing whether backups ran successfully in the last 24 hours"
55

66
report_delivery_channel {

infrastructure/modules/aws-backup-source/backup_report_plan_backup_restore_testing_jobs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Create the restore testing completion reports
22
resource "aws_backup_report_plan" "backup_restore_testing_jobs" {
3-
name = "backup_restore_testing_jobs"
3+
name = "${local.csi_underscore}_backup_restore_testing_jobs"
44
description = "Report for showing whether backup restore test ran successfully in the last 24 hours"
55

66
report_delivery_channel {

infrastructure/modules/aws-backup-source/backup_report_plan_copy_jobs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
resource "aws_backup_report_plan" "copy_jobs" {
22
count = var.backup_copy_vault_arn != "" && var.backup_copy_vault_account_id != "" ? 1 : 0
33

4-
name = "copy_jobs"
4+
name = "${local.csi_underscore}_copy_jobs"
55
description = "Report for showing whether copies ran successfully in the last 24 hours"
66

77
report_delivery_channel {

infrastructure/modules/aws-backup-source/backup_report_plan_resource_compliance.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_backup_report_plan" "resource_compliance" {
2-
name = "resource_compliance"
2+
name = "${local.csi_underscore}_resource_compliance"
33
description = "Report for showing whether resources are compliant with the framework"
44

55
report_delivery_channel {

infrastructure/modules/aws-backup-source/backup_restore_testing_plan.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "awscc_backup_restore_testing_plan" "main" {
2-
restore_testing_plan_name = local.resource_name_prefix
2+
restore_testing_plan_name = local.csi_underscore
33
schedule_expression = var.restore_testing_plan_scheduled_expression
44
start_window_hours = var.restore_testing_plan_start_window
55
recovery_point_selection = {

0 commit comments

Comments
 (0)