Skip to content

Commit 7144815

Browse files
authored
DS-2843 Enable dynamodb delete protection for live profile (#1040)
# Task Branch Pull Request **<https://nhsd-jira.digital.nhs.uk/browse/DS-2843>** ## Description of Changes This PR change enables the delete protection on change event DB in prod environment. This delete protection not enabled on any other env as we will require to tear the lower envs down after the development/testing purpose is fulfilled and tested in these lower env and hence it's enabled for prod env only to avoid accidental deletion of DB ## Type of change Delete not appropriate - Security enhancement for dynamodb table in prod env ## Development Checklist - [x] I have performed a self-review of my own code - [x] Tests have added that prove my fix is effective or that my feature works (Integration tests) - [x] I have updated Dependabot to include my changes (if applicable) ## Code Reviewer Checklist - [x] I can confirm the changes have been tested or approved by a tester
1 parent 1e79e55 commit 7144815

9 files changed

Lines changed: 13 additions & 0 deletions

File tree

build/automation/var/profile/demo.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
4040

4141
# WAF
4242
WAF_ENABLED := true
43+
DDB_DELETE_PROTECTION :=false
4344

4445
# ==============================================================================
4546
# Performance variables

build/automation/var/profile/dev.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
3939

4040
# WAF
4141
WAF_ENABLED := false
42+
DDB_DELETE_PROTECTION :=false
4243

4344
# ==============================================================================
4445
# Performance variables

build/automation/var/profile/live.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SLACK_ALERT_CHANNEL := dos-integration-live-status
4141

4242
# WAF
4343
WAF_ENABLED := true
44+
DDB_DELETE_PROTECTION :=true
4445

4546
# ==============================================================================
4647
# Performance variables

build/automation/var/profile/pen.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22

33
# WAF
44
WAF_ENABLED := true
5+
DDB_DELETE_PROTECTION :=false

build/automation/var/profile/perf.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
3939

4040
# WAF
4141
WAF_ENABLED := true
42+
DDB_DELETE_PROTECTION :=false
4243

4344
# ==============================================================================
4445
# Performance variables

build/automation/var/profile/perf2.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ SLACK_ALERT_CHANNEL := dos-integration-dev-status
3939

4040
# WAF
4141
WAF_ENABLED := true
42+
DDB_DELETE_PROTECTION :=false
4243

4344
# ==============================================================================
4445
# Performance variables

build/automation/var/project.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ TF_VAR_change_event_dlq := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-change-event-dead
109109
# Dynamodb
110110
TF_VAR_change_events_table_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-change-events
111111
DYNAMO_DB_TABLE := $(TF_VAR_change_events_table_name)
112+
TF_VAR_ddb_delete_protection :=$(DDB_DELETE_PROTECTION)
112113

113114
# Log Group Filters for Firehose
114115
TF_VAR_change_event_gateway_subscription_filter_name := $(PROJECT_ID)-$(SHARED_ENVIRONMENT)-change-event-api-gateway-cw-logs-firehose-subscription

infrastructure/stacks/shared-resources/dynamodb.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ resource "aws_dynamodb_table" "message-history-table" {
33
billing_mode = "PAY_PER_REQUEST"
44
hash_key = "Id"
55
range_key = "ODSCode"
6+
deletion_protection_enabled = var.ddb_delete_protection
67

78
server_side_encryption {
89
enabled = true

infrastructure/stacks/shared-resources/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ variable "waf_enabled" {
158158
description = "Whether to enable WAF"
159159
}
160160

161+
variable "ddb_delete_protection" {
162+
type = bool
163+
description = "Whether to enable delete protection"
164+
}
165+
161166
variable "waf_acl_name" {
162167
type = string
163168
description = "Name of the WAF ACL"

0 commit comments

Comments
 (0)