Skip to content

Commit 504f15c

Browse files
authored
[PRMP-809] Add S3 event trigger for document review prefix (#518)
Signed-off-by: NogaNHS <[email protected]>
1 parent bd6b99f commit 504f15c

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

infrastructure/buckets.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,18 @@ resource "aws_s3_bucket_lifecycle_configuration" "staging-store-lifecycle-rules"
233233
prefix = "user_upload/"
234234
}
235235
}
236+
rule {
237+
id = "Delete objects in review folder that have existed for 24 hours"
238+
status = "Enabled"
239+
240+
expiration {
241+
days = 1
242+
}
243+
244+
filter {
245+
prefix = "review/"
246+
}
247+
}
236248
rule {
237249
id = "default-to-intelligent-tiering"
238250
status = "Enabled"

infrastructure/lambda-document-upload-check.tf

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,27 @@ module "document_upload_check_lambda" {
1212
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
1313
module.pdm_dynamodb_table.dynamodb_read_policy_document,
1414
module.pdm_dynamodb_table.dynamodb_write_policy_document,
15+
data.aws_iam_policy.aws_lambda_vpc_access_execution_role.policy,
16+
local.is_production ? "" : module.document_review_dynamodb_table[0].dynamodb_read_policy_document,
17+
local.is_production ? "" : module.document_review_dynamodb_table[0].dynamodb_write_policy_document,
18+
module.ndr-document-pending-review-store.s3_write_policy_document,
1519
module.core_dynamodb_table.dynamodb_read_policy_document,
1620
module.core_dynamodb_table.dynamodb_write_policy_document,
17-
data.aws_iam_policy.aws_lambda_vpc_access_execution_role.policy
1821
]
1922
kms_deletion_window = var.kms_deletion_window
2023
rest_api_id = null
2124
http_methods = null
2225
api_execution_arn = null
2326
lambda_environment_variables = {
24-
LLOYD_GEORGE_DYNAMODB_NAME = module.lloyd_george_reference_dynamodb_table.table_name
25-
PDM_DYNAMODB_NAME = module.pdm_dynamodb_table.table_name
26-
STAGING_STORE_BUCKET_NAME = module.ndr-bulk-staging-store.bucket_id
27-
LLOYD_GEORGE_BUCKET_NAME = module.ndr-lloyd-george-store.bucket_id
28-
PDM_BUCKET_NAME = module.pdm-document-store.bucket_id
29-
WORKSPACE = terraform.workspace
30-
VIRUS_SCAN_STUB = !local.is_production
27+
LLOYD_GEORGE_DYNAMODB_NAME = module.lloyd_george_reference_dynamodb_table.table_name
28+
DOCUMENT_REVIEW_DYNAMODB_NAME = local.is_production ? "" : module.document_review_dynamodb_table[0].table_name
29+
PDM_DYNAMODB_NAME = module.pdm_dynamodb_table.table_name
30+
STAGING_STORE_BUCKET_NAME = module.ndr-bulk-staging-store.bucket_id
31+
LLOYD_GEORGE_BUCKET_NAME = module.ndr-lloyd-george-store.bucket_id
32+
PDM_BUCKET_NAME = module.pdm-document-store.bucket_id
33+
PENDING_REVIEW_BUCKET_NAME = module.ndr-document-pending-review-store.bucket_id
34+
WORKSPACE = terraform.workspace
35+
VIRUS_SCAN_STUB = !local.is_production
3136

3237
}
3338
lambda_timeout = 900
@@ -68,6 +73,11 @@ resource "aws_s3_bucket_notification" "document_upload_check_lambda_trigger" {
6873
events = ["s3:ObjectCreated:*"]
6974
filter_prefix = "fhir_upload"
7075
}
76+
lambda_function {
77+
lambda_function_arn = module.document_upload_check_lambda.lambda_arn
78+
events = ["s3:ObjectCreated:*"]
79+
filter_prefix = "review"
80+
}
7181
}
7282

7383
resource "aws_lambda_permission" "document_upload_check_lambda" {

0 commit comments

Comments
 (0)