Skip to content

Commit 2a159e4

Browse files
Merge remote-tracking branch 'origin' into PRMP-1553
2 parents 2e917eb + f127786 commit 2a159e4

File tree

3 files changed

+60
-9
lines changed

3 files changed

+60
-9
lines changed

infrastructure/lambda-bulk-upload.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module "bulk-upload-lambda" {
1212
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
1313
module.bulk_upload_report_dynamodb_table.dynamodb_read_policy_document,
1414
module.bulk_upload_report_dynamodb_table.dynamodb_write_policy_document,
15-
module.sqs-nrl-queue.sqs_write_policy_document,
15+
module.sqs-stitching-queue.sqs_write_policy_document,
1616
module.sqs-lg-bulk-upload-metadata-queue.sqs_read_policy_document,
1717
module.sqs-lg-bulk-upload-metadata-queue.sqs_write_policy_document,
1818
module.sqs-lg-bulk-upload-invalid-queue.sqs_read_policy_document,
@@ -35,7 +35,7 @@ module "bulk-upload-lambda" {
3535
METADATA_SQS_QUEUE_URL = module.sqs-lg-bulk-upload-metadata-queue.sqs_url
3636
INVALID_SQS_QUEUE_URL = module.sqs-lg-bulk-upload-invalid-queue.sqs_url
3737
PDS_FHIR_IS_STUBBED = local.is_sandbox
38-
NRL_SQS_URL = module.sqs-nrl-queue.sqs_url
38+
PDF_STITCHING_SQS_URL = module.sqs-stitching-queue.sqs_url
3939
APIM_API_URL = data.aws_ssm_parameter.apim_url.value
4040
}
4141

infrastructure/lambda-pdf-stitching.tf

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ module "pdf-stitching-lambda" {
55
memory_size = 1769
66
lambda_timeout = 900
77
iam_role_policy_documents = [
8-
module.ndr-lloyd-george-store.s3_read_policy_document,
98
module.sqs-nrl-queue.sqs_read_policy_document,
109
module.sqs-nrl-queue.sqs_write_policy_document,
1110
module.sqs-stitching-queue.sqs_read_policy_document,
1211
module.sqs-stitching-queue.sqs_write_policy_document,
1312
module.lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
1413
module.lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
1514
module.unstitched_lloyd_george_reference_dynamodb_table.dynamodb_write_policy_document,
16-
module.unstitched_lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document
15+
module.unstitched_lloyd_george_reference_dynamodb_table.dynamodb_read_policy_document,
16+
module.ndr-lloyd-george-store.s3_read_policy_document,
17+
module.ndr-lloyd-george-store.s3_write_policy_document,
1718
]
1819
rest_api_id = null
1920
api_execution_arn = null
2021
is_invoked_from_gateway = false
2122
lambda_environment_variables = {
22-
STITCH_SQS_QUEUE_URL = module.sqs-stitching-queue.sqs_url
23-
NRL_SQS_QUEUE_URL = module.sqs-nrl-queue.sqs_url
24-
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
25-
STITCH_METADATA_DYNAMODB_NAME = "${terraform.workspace}_${var.unstitched_lloyd_george_dynamodb_table_name}"
26-
WORKSPACE = terraform.workspace
23+
PDF_STITCHING_SQS_URL = module.sqs-stitching-queue.sqs_url
24+
NRL_SQS_URL = module.sqs-nrl-queue.sqs_url
25+
LLOYD_GEORGE_BUCKET_NAME = "${terraform.workspace}-${var.lloyd_george_bucket_name}"
26+
LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.lloyd_george_dynamodb_table_name}"
27+
UNSTITCHED_LLOYD_GEORGE_DYNAMODB_NAME = "${terraform.workspace}_${var.unstitched_lloyd_george_dynamodb_table_name}"
28+
WORKSPACE = terraform.workspace
2729
}
2830
}
2931

infrastructure/sqs-stitching.tf

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,52 @@ module "sqs-stitching-queue" {
88
max_visibility = 1200
99
enable_dlq = true
1010
}
11+
12+
resource "aws_cloudwatch_metric_alarm" "stitching_dlq_new_messages" {
13+
alarm_name = "${terraform.workspace}_stitching_dlq_messages"
14+
comparison_operator = "GreaterThanThreshold"
15+
evaluation_periods = 1
16+
metric_name = "ApproximateNumberOfMessagesVisible"
17+
namespace = "AWS/SQS"
18+
period = 60
19+
statistic = "Sum"
20+
threshold = 0
21+
alarm_description = "Alarm when there are new messages in the stitching dlq"
22+
alarm_actions = [module.stitching-dlq-alarm-topic.arn]
23+
24+
dimensions = {
25+
QueueName = module.sqs-stitching-queue.dlq_name
26+
}
27+
}
28+
29+
module "stitching-dlq-alarm-topic" {
30+
source = "./modules/sns"
31+
sns_encryption_key_id = module.sns_encryption_key.id
32+
current_account_id = data.aws_caller_identity.current.account_id
33+
topic_name = "stitching-dlq-topic"
34+
topic_protocol = "email"
35+
is_topic_endpoint_list = true
36+
topic_endpoint_list = nonsensitive(split(",", data.aws_ssm_parameter.cloud_security_notification_email_list.value))
37+
delivery_policy = jsonencode({
38+
"Version" : "2012-10-17",
39+
"Statement" : [
40+
{
41+
"Effect" : "Allow",
42+
"Principal" : {
43+
"Service" : "cloudwatch.amazonaws.com"
44+
},
45+
"Action" : [
46+
"SNS:Publish",
47+
],
48+
"Condition" : {
49+
"ArnLike" : {
50+
"aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*"
51+
}
52+
}
53+
"Resource" : "*"
54+
}
55+
]
56+
})
57+
58+
depends_on = [module.sqs-stitching-queue]
59+
}

0 commit comments

Comments
 (0)