Skip to content

Commit 8fe7776

Browse files
[PRME-125] Modify Upload Status Lambda to Document Status Lambda (#386)
Co-authored-by: adamwhitingnhs <[email protected]>
1 parent c9b5bdf commit 8fe7776

File tree

5 files changed

+46
-38
lines changed

5 files changed

+46
-38
lines changed

infrastructure/api.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ resource "aws_api_gateway_deployment" "ndr_api_deploy" {
7070
module.send-feedback-lambda,
7171
module.update-upload-state-gateway,
7272
module.update-upload-state-lambda,
73-
module.upload_confirm_result_gateway,
74-
module.upload_confirm_result_lambda,
73+
module.document-status-check-gateway,
74+
module.document-status-check-lambda,
7575
module.post-document-references-fhir-lambda,
7676
module.virus_scan_result_gateway,
7777
module.virus_scan_result_lambda

infrastructure/lambda-upload-confirm-result.tf renamed to infrastructure/lambda-document-status-check-result.tf

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
module "upload_confirm_result_gateway" {
1+
module "document-status-check-gateway" {
22
source = "./modules/gateway"
33
api_gateway_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
44
parent_id = aws_api_gateway_rest_api.ndr_doc_store_api.root_resource_id
5-
http_methods = ["POST"]
5+
http_methods = ["GET"]
66
authorization = "CUSTOM"
7-
gateway_path = "UploadConfirm"
7+
gateway_path = "DocumentStatus"
88
authorizer_id = aws_api_gateway_authorizer.repo_authoriser.id
99
require_credentials = true
1010
origin = contains(["prod"], terraform.workspace) ? "'https://${var.domain}'" : "'https://${terraform.workspace}.${var.domain}'"
1111
}
1212

13-
module "upload_confirm_result_alarm" {
13+
module "document-status-check-alarm" {
1414
source = "./modules/lambda_alarms"
15-
lambda_function_name = module.upload_confirm_result_lambda.function_name
16-
lambda_timeout = module.upload_confirm_result_lambda.timeout
17-
lambda_name = "upload_confirm_result_handler"
15+
lambda_function_name = module.document-status-check-lambda.function_name
16+
lambda_timeout = module.document-status-check-lambda.timeout
17+
lambda_name = "document_status_check_handler"
1818
namespace = "AWS/Lambda"
19-
alarm_actions = [module.upload_confirm_result_alarm_topic.arn]
20-
ok_actions = [module.upload_confirm_result_alarm_topic.arn]
21-
depends_on = [module.upload_confirm_result_lambda, module.upload_confirm_result_alarm_topic]
19+
alarm_actions = [module.document-status-check-alarm-topic.arn]
20+
ok_actions = [module.document-status-check-alarm-topic.arn]
21+
depends_on = [module.document-status-check-lambda, module.document-status-check-alarm-topic]
2222
}
2323

2424

25-
module "upload_confirm_result_alarm_topic" {
25+
module "document-status-check-alarm-topic" {
2626
source = "./modules/sns"
2727
sns_encryption_key_id = module.sns_encryption_key.id
28-
topic_name = "upload_confirm_result_alarm-topic"
28+
topic_name = "document-status-check-alarm-topic"
2929
topic_protocol = "lambda"
30-
topic_endpoint = module.upload_confirm_result_lambda.lambda_arn
30+
topic_endpoint = module.document-status-check-lambda.lambda_arn
3131
depends_on = [module.sns_encryption_key]
3232
delivery_policy = jsonencode({
3333
"Version" : "2012-10-17",
@@ -51,48 +51,34 @@ module "upload_confirm_result_alarm_topic" {
5151
})
5252
}
5353

54-
module "upload_confirm_result_lambda" {
54+
module "document-status-check-lambda" {
5555
source = "./modules/lambda"
56-
name = "UploadConfirmResultLambda"
57-
handler = "handlers.upload_confirm_result_handler.lambda_handler"
56+
name = "DocumentStatusCheckLambda"
57+
handler = "handlers.document_status_check_handler.lambda_handler"
5858
iam_role_policy_documents = [
5959
module.ndr-app-config.app_config_policy,
60-
module.ndr-bulk-staging-store.s3_read_policy_document,
61-
module.ndr-bulk-staging-store.s3_write_policy_document,
62-
module.ndr-document-store.s3_read_policy_document,
63-
module.ndr-document-store.s3_write_policy_document,
64-
module.ndr-lloyd-george-store.s3_read_policy_document,
65-
module.ndr-lloyd-george-store.s3_write_policy_document,
6660
module.document_reference_dynamodb_table.dynamodb_read_policy_document,
6761
module.document_reference_dynamodb_table.dynamodb_write_policy_document,
6862
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
6963
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
70-
module.sqs-nrl-queue.sqs_write_policy_document,
7164
]
7265
rest_api_id = aws_api_gateway_rest_api.ndr_doc_store_api.id
73-
resource_id = module.upload_confirm_result_gateway.gateway_resource_id
74-
http_methods = ["POST"]
66+
resource_id = module.document-status-check-gateway.gateway_resource_id
67+
http_methods = ["GET"]
7568
api_execution_arn = aws_api_gateway_rest_api.ndr_doc_store_api.execution_arn
7669
lambda_environment_variables = {
7770
APPCONFIG_APPLICATION = module.ndr-app-config.app_config_application_id
7871
APPCONFIG_ENVIRONMENT = module.ndr-app-config.app_config_environment_id
7972
APPCONFIG_CONFIGURATION = module.ndr-app-config.app_config_configuration_profile_id
80-
STAGING_STORE_BUCKET_NAME = "${terraform.workspace}-${var.staging_store_bucket_name}"
81-
LLOYD_GEORGE_BUCKET_NAME = "${terraform.workspace}-${var.lloyd_george_bucket_name}"
82-
DOCUMENT_STORE_BUCKET_NAME = "${terraform.workspace}-${var.docstore_bucket_name}"
8373
DOCUMENT_STORE_DYNAMODB_NAME = "${terraform.workspace}_${var.docstore_dynamodb_table_name}"
8474
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
8575
WORKSPACE = terraform.workspace
86-
APIM_API_URL = data.aws_ssm_parameter.apim_url.value
87-
NRL_SQS_URL = module.sqs-nrl-queue.sqs_url
8876
}
8977
depends_on = [
9078
aws_api_gateway_rest_api.ndr_doc_store_api,
9179
module.ndr-bulk-staging-store,
92-
module.upload_confirm_result_gateway,
80+
module.document-status-check-gateway,
9381
module.ndr-app-config,
94-
module.ndr-lloyd-george-store,
95-
module.ndr-document-store,
9682
module.lloyd_george_reference_dynamodb_table,
9783
module.document_reference_dynamodb_table,
9884
]

infrastructure/lambda-document-upload-check.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "document_upload_check_lambda" {
2-
count = local.is_production ? 0 : 1
2+
count = 1
33
source = "./modules/lambda"
44
name = "DocumentReferenceVirusScanCheck"
55
handler = "handlers.document_reference_virus_scan_handler.lambda_handler"
@@ -35,7 +35,7 @@ module "document_upload_check_lambda" {
3535

3636

3737
resource "aws_s3_bucket_notification" "document_upload_check_lambda_trigger" {
38-
count = local.is_production ? 0 : 1
38+
count = 1
3939
bucket = module.ndr-bulk-staging-store.bucket_id
4040
lambda_function {
4141
lambda_function_arn = module.document_upload_check_lambda[0].lambda_arn
@@ -45,7 +45,7 @@ resource "aws_s3_bucket_notification" "document_upload_check_lambda_trigger" {
4545
}
4646

4747
resource "aws_lambda_permission" "document_upload_check_lambda" {
48-
count = local.is_production ? 0 : 1
48+
count = 1
4949
statement_id = "AllowS3Invoke"
5050
action = "lambda:InvokeFunction"
5151
function_name = module.document_upload_check_lambda[0].function_name

infrastructure/modules/dynamo_db/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ data "aws_iam_policy_document" "dynamodb_read_policy" {
8888
"dynamodb:Query",
8989
"dynamodb:Scan",
9090
"dynamodb:GetItem",
91+
"dynamodb:BatchGetItem"
9192
]
9293
resources = [
9394
aws_dynamodb_table.ndr_dynamodb_table.arn,

infrastructure/moved-resources.tf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
11
moved {
22
from = module.document_reference_gateway
33
to = module.create_document_reference_gateway
4+
}
5+
6+
#PRME-125
7+
moved {
8+
from = module.upload_confirm_result_gateway
9+
to = module.document-status-check-gateway
10+
}
11+
12+
moved {
13+
from = module.upload_confirm_result_lambda
14+
to = module.document-status-check-lambda
15+
}
16+
17+
moved {
18+
from = module.upload_confirm_result_alarm
19+
to = module.document-status-check-alarm
20+
}
21+
22+
moved {
23+
from = module.upload_confirm_result_alarm_topic
24+
to = module.document-status-check-alarm-topic
425
}

0 commit comments

Comments
 (0)