Skip to content

Commit ee8a325

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

7 files changed

Lines changed: 116 additions & 48 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 {
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
environment = "preprod"
2-
immunisation_account_id = "084828561157"
3-
dspp_core_account_id = "603871901111"
4-
pds_environment = "int"
5-
batch_error_notifications_enabled = true
6-
create_mesh_processor = true
7-
has_sub_environment_scope = false
1+
environment = "preprod"
2+
immunisation_account_id = "084828561157"
3+
dspp_core_account_id = "603871901111"
4+
pds_environment = "int"
5+
batch_error_notifications_enabled = true
6+
create_mesh_processor = true
7+
has_sub_environment_scope = false
8+
dynamodb_point_in_time_recovery_enabled = true
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
environment = "preprod"
2-
immunisation_account_id = "084828561157"
3-
dspp_core_account_id = "603871901111"
4-
pds_environment = "int"
5-
batch_error_notifications_enabled = true
6-
create_mesh_processor = true
7-
has_sub_environment_scope = false
1+
environment = "preprod"
2+
immunisation_account_id = "084828561157"
3+
dspp_core_account_id = "603871901111"
4+
pds_environment = "int"
5+
batch_error_notifications_enabled = true
6+
create_mesh_processor = true
7+
has_sub_environment_scope = false
8+
dynamodb_point_in_time_recovery_enabled = true
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
environment = "prod"
2-
immunisation_account_id = "664418956997"
3-
dspp_core_account_id = "232116723729"
4-
mns_account_id = "758334270304"
5-
pds_environment = "prod"
6-
batch_error_notifications_enabled = true
7-
create_mesh_processor = true
8-
has_sub_environment_scope = false
9-
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
10-
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
1+
environment = "prod"
2+
immunisation_account_id = "664418956997"
3+
dspp_core_account_id = "232116723729"
4+
mns_account_id = "758334270304"
5+
pds_environment = "prod"
6+
batch_error_notifications_enabled = true
7+
create_mesh_processor = true
8+
has_sub_environment_scope = false
9+
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
10+
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
11+
dynamodb_point_in_time_recovery_enabled = true
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
environment = "prod"
2-
immunisation_account_id = "664418956997"
3-
dspp_core_account_id = "232116723729"
4-
mns_account_id = "758334270304"
5-
pds_environment = "prod"
6-
batch_error_notifications_enabled = true
7-
create_mesh_processor = true
8-
has_sub_environment_scope = false
9-
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
10-
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
1+
environment = "prod"
2+
immunisation_account_id = "664418956997"
3+
dspp_core_account_id = "232116723729"
4+
mns_account_id = "758334270304"
5+
pds_environment = "prod"
6+
batch_error_notifications_enabled = true
7+
create_mesh_processor = true
8+
has_sub_environment_scope = false
9+
dspp_submission_s3_bucket_name = "nhsd-dspp-core-prod-s3-submission-upload"
10+
dspp_submission_kms_key_alias = "nhsd-dspp-core-prod-s3-submission-upload-key"
11+
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
@@ -117,6 +117,13 @@ resource "aws_s3_bucket_public_access_block" "batch_data_destination_bucket_publ
117117
restrict_public_buckets = true
118118
}
119119

120+
resource "aws_s3_bucket_versioning" "batch_data_destination" {
121+
bucket = aws_s3_bucket.batch_data_destination_bucket.bucket
122+
versioning_configuration {
123+
status = "Enabled"
124+
}
125+
}
126+
120127
resource "aws_s3_bucket_policy" "batch_data_destination_bucket_policy" {
121128
bucket = aws_s3_bucket.batch_data_destination_bucket.id
122129
policy = jsonencode({
@@ -215,6 +222,13 @@ resource "aws_s3_bucket_public_access_block" "batch_config_bucket_public_access_
215222
restrict_public_buckets = true
216223
}
217224

225+
resource "aws_s3_bucket_versioning" "batch_config" {
226+
bucket = aws_s3_bucket.batch_config_bucket.bucket
227+
versioning_configuration {
228+
status = "Enabled"
229+
}
230+
}
231+
218232
resource "aws_s3_bucket_policy" "batch_config_bucket_policy" {
219233
bucket = aws_s3_bucket.batch_config_bucket.id
220234

infrastructure/instance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,12 @@ variable "has_sub_environment_scope" {
8181
default = false
8282
}
8383

84+
variable "dynamodb_point_in_time_recovery_enabled" {
85+
description = "Whether to enable PITR on DynamoDB tables"
86+
type = bool
87+
default = false
88+
}
89+
8490
locals {
8591
prefix = "${var.project_name}-${var.service}-${var.sub_environment}"
8692
short_prefix = "${var.project_short_name}-${var.sub_environment}"

0 commit comments

Comments
 (0)