Skip to content

Commit 9c48bc7

Browse files
jack-nhsJuttonS
andauthored
[PRMP-1505] Infrastructure for PDF stitching lambda (#247)
* Prevents http requests being made to logs store s3 bucket * Starts to create infrastructure for new pdf stitcher lambda * Starts to provision lambda pdf stitcher infrastructure * Formatting * Remove unnecessary vars from dev file * Formatting * Renames file * Remove duplicate DLQ and add trigger and alarms for lambda * adds missing quote * corrected sqs referencing * formatting * increases visibility on sqs stitching queue * Changes lambda name to conventional format * Fixes naming conventions * Linting * Names handler correctly * Removes unnecessary dependancies --------- Co-authored-by: Jack Sutton <[email protected]>
1 parent 054ab60 commit 9c48bc7

File tree

5 files changed

+79
-5
lines changed

5 files changed

+79
-5
lines changed

bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
| Name | Version |
1111
|------|---------|
12-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.70.0 |
12+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.0 |
1313

1414
## Modules
1515

infrastructure/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
| Name | Version |
1010
|------|---------|
11-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.86.1 |
11+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 5.73.0 |
1212

1313
## Modules
1414

@@ -111,6 +111,9 @@
111111
| <a name="module_nems-message-lambda-alarm"></a> [nems-message-lambda-alarm](#module\_nems-message-lambda-alarm) | ./modules/lambda_alarms | n/a |
112112
| <a name="module_nems-message-lambda-alarm-topic"></a> [nems-message-lambda-alarm-topic](#module\_nems-message-lambda-alarm-topic) | ./modules/sns | n/a |
113113
| <a name="module_nrl-dlq-alarm-topic"></a> [nrl-dlq-alarm-topic](#module\_nrl-dlq-alarm-topic) | ./modules/sns | n/a |
114+
| <a name="module_pdf-stitching-alarm-topic"></a> [pdf-stitching-alarm-topic](#module\_pdf-stitching-alarm-topic) | ./modules/sns | n/a |
115+
| <a name="module_pdf-stitching-lambda"></a> [pdf-stitching-lambda](#module\_pdf-stitching-lambda) | ./modules/lambda | n/a |
116+
| <a name="module_pdf-stitching-lambda-alarms"></a> [pdf-stitching-lambda-alarms](#module\_pdf-stitching-lambda-alarms) | ./modules/lambda_alarms | n/a |
114117
| <a name="module_route53_fargate_ui"></a> [route53\_fargate\_ui](#module\_route53\_fargate\_ui) | ./modules/route53 | n/a |
115118
| <a name="module_search-document-references-gateway"></a> [search-document-references-gateway](#module\_search-document-references-gateway) | ./modules/gateway | n/a |
116119
| <a name="module_search-document-references-lambda"></a> [search-document-references-lambda](#module\_search-document-references-lambda) | ./modules/lambda | n/a |
@@ -132,6 +135,7 @@
132135
| <a name="module_sqs-nems-queue"></a> [sqs-nems-queue](#module\_sqs-nems-queue) | ./modules/sqs | n/a |
133136
| <a name="module_sqs-nrl-queue"></a> [sqs-nrl-queue](#module\_sqs-nrl-queue) | ./modules/sqs | n/a |
134137
| <a name="module_sqs-splunk-queue"></a> [sqs-splunk-queue](#module\_sqs-splunk-queue) | ./modules/sqs | n/a |
138+
| <a name="module_sqs-stitching-queue"></a> [sqs-stitching-queue](#module\_sqs-stitching-queue) | ./modules/sqs | n/a |
135139
| <a name="module_statistical-report-alarm"></a> [statistical-report-alarm](#module\_statistical-report-alarm) | ./modules/lambda_alarms | n/a |
136140
| <a name="module_statistical-report-alarm-topic"></a> [statistical-report-alarm-topic](#module\_statistical-report-alarm-topic) | ./modules/sns | n/a |
137141
| <a name="module_statistical-report-lambda"></a> [statistical-report-lambda](#module\_statistical-report-lambda) | ./modules/lambda | n/a |
@@ -286,6 +290,7 @@
286290
| [aws_lambda_event_source_mapping.mns_notification_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource |
287291
| [aws_lambda_event_source_mapping.nems_message_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource |
288292
| [aws_lambda_event_source_mapping.nrl_pointer_lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource |
293+
| [aws_lambda_event_source_mapping.pdf-stitching-lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_event_source_mapping) | resource |
289294
| [aws_lambda_permission.bulk_upload_metadata_schedule_permission](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
290295
| [aws_lambda_permission.bulk_upload_report_schedule_permission](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
291296
| [aws_lambda_permission.data_collection_schedule_permission](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |

infrastructure/dev.tfvars

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@ mesh_client_cert_ssm_param_name = "/repo/dev/user-input/external/mesh-mailbox-cl
1515
mesh_client_key_ssm_param_name = "/repo/dev/user-input/external/mesh-mailbox-client-key"
1616
mesh_ca_cert_ssm_param_name = "/repo/dev/user-input/external/mesh-mailbox-ca-cert"
1717

18-
standalone_vpc_tag = "ndr-dev"
19-
standalone_vpc_ig_tag = "ndr-dev"
20-
cloud_security_email_param_environment = "dev"
18+
standalone_vpc_tag = "ndr-dev"
19+
standalone_vpc_ig_tag = "ndr-dev"
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
module "pdf-stitching-lambda" {
2+
source = "./modules/lambda"
3+
name = "PdfStitchingLambda"
4+
handler = "handlers.pdf_stitching_handler.lambda_handler"
5+
lambda_timeout = 900
6+
iam_role_policy_documents = [
7+
module.ndr-lloyd-george-store.s3_write_policy_document,
8+
module.ndr-lloyd-george-store.s3_read_policy_document,
9+
module.sqs-nrl-queue.sqs_write_policy_document,
10+
module.sqs-stitching-queue.sqs_write_policy_document,
11+
module.sqs-stitching-queue.sqs_read_policy_document
12+
]
13+
rest_api_id = null
14+
api_execution_arn = null
15+
is_invoked_from_gateway = false
16+
}
17+
18+
resource "aws_lambda_event_source_mapping" "pdf-stitching-lambda" {
19+
event_source_arn = module.sqs-stitching-queue.endpoint
20+
function_name = module.pdf-stitching-lambda.lambda_arn
21+
}
22+
23+
module "pdf-stitching-lambda-alarms" {
24+
source = "./modules/lambda_alarms"
25+
lambda_function_name = module.pdf-stitching-lambda.function_name
26+
lambda_timeout = module.pdf-stitching-lambda.timeout
27+
lambda_name = "PdfStitchingLambda"
28+
namespace = "AWS/Lambda"
29+
alarm_actions = [module.pdf-stitching-alarm-topic.arn]
30+
ok_actions = [module.pdf-stitching-alarm-topic.arn]
31+
}
32+
33+
module "pdf-stitching-alarm-topic" {
34+
source = "./modules/sns"
35+
sns_encryption_key_id = module.sns_encryption_key.id
36+
current_account_id = data.aws_caller_identity.current.account_id
37+
topic_name = "pdf-stitching-alarm-topic"
38+
topic_protocol = "lambda"
39+
topic_endpoint = module.pdf-stitching-lambda.lambda_arn
40+
delivery_policy = jsonencode({
41+
"Version" : "2012-10-17",
42+
"Statement" : [
43+
{
44+
"Effect" : "Allow",
45+
"Principal" : {
46+
"Service" : "cloudwatch.amazonaws.com"
47+
},
48+
"Action" : [
49+
"SNS:Publish",
50+
],
51+
"Condition" : {
52+
"ArnLike" : {
53+
"aws:SourceArn" : "arn:aws:cloudwatch:eu-west-2:${data.aws_caller_identity.current.account_id}:alarm:*"
54+
}
55+
}
56+
"Resource" : "*"
57+
}
58+
]
59+
})
60+
}

infrastructure/sqs-stitching.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module "sqs-stitching-queue" {
2+
source = "./modules/sqs"
3+
name = "stitching-queue"
4+
environment = var.environment
5+
owner = var.owner
6+
message_retention = 1800
7+
enable_sse = true
8+
max_visibility = 1200
9+
enable_dlq = true
10+
}

0 commit comments

Comments
 (0)