Skip to content

Commit 3461824

Browse files
authored
VED-1050: Enable PITR in preprod and enable S3 versioning on additional buckets. (#1232)
1 parent de80070 commit 3461824

7 files changed

Lines changed: 98 additions & 30 deletions

File tree

infrastructure/instance/dynamodb.tf

Lines changed: 58 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,31 @@ resource "aws_dynamodb_table" "audit-table" {
3131

3232
global_secondary_index {
3333
name = "filename_index"
34-
hash_key = "filename"
3534
projection_type = "ALL"
35+
36+
key_schema {
37+
attribute_name = "filename"
38+
key_type = "HASH"
39+
}
3640
}
3741

3842
global_secondary_index {
3943
name = "queue_name_index"
40-
hash_key = "queue_name"
41-
range_key = "status"
4244
projection_type = "ALL"
45+
46+
key_schema {
47+
attribute_name = "queue_name"
48+
key_type = "HASH"
49+
}
50+
51+
key_schema {
52+
attribute_name = "status"
53+
key_type = "RANGE"
54+
}
4355
}
4456

4557
point_in_time_recovery {
46-
enabled = var.environment == "prod"
58+
enabled = var.dynamodb_point_in_time_recovery_enabled
4759
}
4860

4961
server_side_encryption {
@@ -95,26 +107,46 @@ resource "aws_dynamodb_table" "delta-dynamodb-table" {
95107

96108
global_secondary_index {
97109
name = "SearchIndex"
98-
hash_key = "Operation"
99-
range_key = "DateTimeStamp"
100110
projection_type = "ALL"
111+
112+
key_schema {
113+
attribute_name = "Operation"
114+
key_type = "HASH"
115+
}
116+
117+
key_schema {
118+
attribute_name = "DateTimeStamp"
119+
key_type = "RANGE"
120+
}
101121
}
102122

103123
global_secondary_index {
104124
name = "SecondarySearchIndex"
105-
hash_key = "SupplierSystem"
106-
range_key = "VaccineType"
107125
projection_type = "ALL"
126+
127+
key_schema {
128+
attribute_name = "SupplierSystem"
129+
key_type = "HASH"
130+
}
131+
132+
key_schema {
133+
attribute_name = "VaccineType"
134+
key_type = "RANGE"
135+
}
108136
}
109137

110138
global_secondary_index {
111139
name = "ImmunisationIdIndex"
112-
hash_key = "ImmsID"
113140
projection_type = "ALL"
141+
142+
key_schema {
143+
attribute_name = "ImmsID"
144+
key_type = "HASH"
145+
}
114146
}
115147

116148
point_in_time_recovery {
117-
enabled = var.environment == "prod"
149+
enabled = var.dynamodb_point_in_time_recovery_enabled
118150
}
119151

120152
server_side_encryption {
@@ -154,19 +186,31 @@ resource "aws_dynamodb_table" "events-dynamodb-table" {
154186

155187
global_secondary_index {
156188
name = "PatientGSI"
157-
hash_key = "PatientPK"
158-
range_key = "PatientSK"
159189
projection_type = "ALL"
190+
191+
key_schema {
192+
attribute_name = "PatientPK"
193+
key_type = "HASH"
194+
}
195+
196+
key_schema {
197+
attribute_name = "PatientSK"
198+
key_type = "RANGE"
199+
}
160200
}
161201

162202
global_secondary_index {
163203
name = "IdentifierGSI"
164-
hash_key = "IdentifierPK"
165204
projection_type = "ALL"
205+
206+
key_schema {
207+
attribute_name = "IdentifierPK"
208+
key_type = "HASH"
209+
}
166210
}
167211

168212
point_in_time_recovery {
169-
enabled = var.environment == "prod"
213+
enabled = var.dynamodb_point_in_time_recovery_enabled
170214
}
171215

172216
server_side_encryption {

infrastructure/instance/environments/preprod/int-blue/variables.tfvars

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pds_environment = "int"
55
error_alarm_notifications_enabled = true
66

77
# mesh no invocation period metric set to 3 days (in seconds) for preprod environment i.e 3 * 24 * 60 * 60
8-
mesh_no_invocation_period_seconds = 259200
9-
create_mesh_processor = true
10-
has_sub_environment_scope = false
8+
mesh_no_invocation_period_seconds = 259200
9+
create_mesh_processor = true
10+
has_sub_environment_scope = false
11+
dynamodb_point_in_time_recovery_enabled = true

infrastructure/instance/environments/preprod/int-green/variables.tfvars

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ pds_environment = "int"
55
error_alarm_notifications_enabled = true
66

77
# mesh no invocation period metric set to 3 days (in seconds) for preprod environment i.e 3 * 24 * 60 * 60
8-
mesh_no_invocation_period_seconds = 259200
9-
create_mesh_processor = true
10-
has_sub_environment_scope = false
8+
mesh_no_invocation_period_seconds = 259200
9+
create_mesh_processor = true
10+
has_sub_environment_scope = false
11+
dynamodb_point_in_time_recovery_enabled = true

infrastructure/instance/environments/prod/blue/variables.tfvars

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ pds_environment = "prod"
66
error_alarm_notifications_enabled = true
77

88
# mesh no invocation period metric set to 1 day (in seconds) for prod environment i.e 1 * 24 * 60 * 60
9-
mesh_no_invocation_period_seconds = 86400
10-
create_mesh_processor = true
11-
has_sub_environment_scope = false
12-
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
13-
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
9+
mesh_no_invocation_period_seconds = 86400
10+
create_mesh_processor = true
11+
has_sub_environment_scope = false
12+
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
13+
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
14+
dynamodb_point_in_time_recovery_enabled = true

infrastructure/instance/environments/prod/green/variables.tfvars

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ pds_environment = "prod"
66
error_alarm_notifications_enabled = true
77

88
# mesh no invocation period metric set to 1 day (in seconds) for prod environment i.e 1 * 24 * 60 * 60
9-
mesh_no_invocation_period_seconds = 86400
10-
create_mesh_processor = true
11-
has_sub_environment_scope = false
12-
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
13-
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
9+
mesh_no_invocation_period_seconds = 86400
10+
create_mesh_processor = true
11+
has_sub_environment_scope = false
12+
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
13+
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
14+
dynamodb_point_in_time_recovery_enabled = true

infrastructure/instance/s3_config.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,13 @@ resource "aws_s3_bucket_public_access_block" "batch_data_destination_bucket_publ
205205
restrict_public_buckets = true
206206
}
207207

208+
resource "aws_s3_bucket_versioning" "batch_data_destination" {
209+
bucket = aws_s3_bucket.batch_data_destination_bucket.bucket
210+
versioning_configuration {
211+
status = "Enabled"
212+
}
213+
}
214+
208215
resource "aws_s3_bucket_policy" "batch_data_destination_bucket_policy" {
209216
bucket = aws_s3_bucket.batch_data_destination_bucket.id
210217
policy = jsonencode({
@@ -303,6 +310,13 @@ resource "aws_s3_bucket_public_access_block" "batch_config_bucket_public_access_
303310
restrict_public_buckets = true
304311
}
305312

313+
resource "aws_s3_bucket_versioning" "batch_config" {
314+
bucket = aws_s3_bucket.batch_config_bucket.bucket
315+
versioning_configuration {
316+
status = "Enabled"
317+
}
318+
}
319+
306320
resource "aws_s3_bucket_policy" "batch_config_bucket_policy" {
307321
bucket = aws_s3_bucket.batch_config_bucket.id
308322

infrastructure/instance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ variable "has_sub_environment_scope" {
9393
default = false
9494
}
9595

96+
variable "dynamodb_point_in_time_recovery_enabled" {
97+
description = "Whether to enable PITR on DynamoDB tables"
98+
type = bool
99+
default = false
100+
}
101+
96102
locals {
97103
prefix = "${var.project_name}-${var.service}-${var.sub_environment}"
98104
short_prefix = "${var.project_short_name}-${var.sub_environment}"

0 commit comments

Comments
 (0)