Skip to content

Commit 98ed4de

Browse files
[PRMP-582] Add DynamoDB table module for document review records (#468)
Co-authored-by: DuncanSangsterNHS <duncan.sangster3@nhs.net>
1 parent b8812d3 commit 98ed4de

File tree

3 files changed

+101
-9
lines changed

3 files changed

+101
-9
lines changed

infrastructure/dynamo_db_review.tf

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
module "document_review_dynamodb_table" {
2+
source = "./modules/dynamo_db"
3+
table_name = var.document_review_table_name
4+
hash_key = "ID"
5+
deletion_protection_enabled = local.is_production
6+
stream_enabled = false
7+
ttl_enabled = true
8+
ttl_attribute_name = "TTL"
9+
point_in_time_recovery_enabled = !local.is_sandbox
10+
11+
attributes = [
12+
{
13+
name = "ID"
14+
type = "S"
15+
},
16+
{
17+
name = "Custodian"
18+
type = "S"
19+
},
20+
{
21+
name = "NhsNumber"
22+
type = "S"
23+
},
24+
{
25+
name = "ReviewStatus"
26+
type = "S"
27+
},
28+
{
29+
name = "Author"
30+
type = "S"
31+
},
32+
{
33+
name = "Reviewer"
34+
type = "S"
35+
},
36+
{
37+
name = "ReviewDate"
38+
type = "S"
39+
},
40+
{
41+
name = "UploadDate"
42+
type = "N"
43+
}
44+
45+
]
46+
47+
global_secondary_indexes = [
48+
{
49+
name = "CustodianIndex"
50+
hash_key = "Custodian"
51+
range_key = "UploadDate"
52+
projection_type = "ALL"
53+
54+
},
55+
{
56+
name = "AuthorIndex"
57+
hash_key = "Author"
58+
range_key = "UploadDate"
59+
projection_type = "ALL"
60+
61+
},
62+
{
63+
name = "ReviewStatusIndex"
64+
hash_key = "ReviewStatus"
65+
range_key = "UploadDate"
66+
projection_type = "ALL"
67+
},
68+
{
69+
name = "ReviewerIndex"
70+
hash_key = "Reviewer"
71+
range_key = "ReviewDate"
72+
projection_type = "ALL"
73+
},
74+
{
75+
name = "NhsNumberIndex"
76+
hash_key = "NhsNumber"
77+
range_key = "UploadDate"
78+
projection_type = "ALL"
79+
}
80+
]
81+
82+
environment = var.environment
83+
owner = var.owner
84+
}

infrastructure/lambda-mns-notification.tf

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ module "mns-notification-lambda" {
88
module.sqs-mns-notification-queue[0].sqs_write_policy_document,
99
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
1010
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
11+
module.document_review_dynamodb_table.dynamodb_write_policy_document,
12+
module.document_review_dynamodb_table.dynamodb_read_policy_document,
1113
aws_iam_policy.ssm_access_policy.policy,
1214
module.ndr-app-config.app_config_policy,
1315
aws_iam_policy.kms_mns_lambda_access[0].policy,
@@ -16,13 +18,14 @@ module "mns-notification-lambda" {
1618
rest_api_id = null
1719
api_execution_arn = null
1820
lambda_environment_variables = {
19-
APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id
20-
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
21-
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
22-
WORKSPACE = terraform.workspace
23-
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
24-
MNS_NOTIFICATION_QUEUE_URL = module.sqs-mns-notification-queue[0].sqs_url
25-
PDS_FHIR_IS_STUBBED = local.is_sandbox
21+
APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id
22+
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
23+
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
24+
WORKSPACE = terraform.workspace
25+
LLOYD_GEORGE_DYNAMODB_NAME = module.lloyd_george_reference_dynamodb_table.table_name
26+
DOCUMENT_REVIEW_DYNAMODB_NAME = module.document_review_dynamodb_table.table_name
27+
MNS_NOTIFICATION_QUEUE_URL = module.sqs-mns-notification-queue[0].sqs_url
28+
PDS_FHIR_IS_STUBBED = local.is_sandbox
2629
}
2730
is_gateway_integration_needed = false
2831
is_invoked_from_gateway = false

infrastructure/variable.tf

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,20 @@ variable "alarm_state_history_table_name" {
161161
default = "AlarmStateHistory"
162162
}
163163

164+
variable "document_review_table_name" {
165+
description = "The name of the DynamoDB table to store document review records."
166+
type = string
167+
default = "DocumentReview"
168+
}
164169
# VPC Variables
165170

166171
variable "standalone_vpc_tag" {
167-
description = "This is the tag assigned to the standalone VPC that should be created manaully before the first run of the infrastructure."
172+
description = "This is the tag assigned to the standalone VPC that should be created manually before the first run of the infrastructure."
168173
type = string
169174
}
170175

171176
variable "standalone_vpc_ig_tag" {
172-
description = "This is the tag assigned to the standalone VPC internet gateway that should be created manaully before the first run of the infrastructure."
177+
description = "This is the tag assigned to the standalone VPC internet gateway that should be created manually before the first run of the infrastructure."
173178
type = string
174179
}
175180

0 commit comments

Comments
 (0)