generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 3
CCM-13475: Send print events #179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
b96894d
CCM-13475: Send print events
simonlabarere b47da0a
CCM-12614: add github package manager authentication
Ian-Hodges d9a4b1a
CCM-12614: add github package manager authentication
Ian-Hodges 883f871
CCM-13475: Github token fix attempt
simonlabarere f2e18ae
CCM-13475: Send print events
simonlabarere cd9ef30
CCM-13475: Send print events
simonlabarere 874098a
CCM-13475: Send print events
simonlabarere a1ce01c
Merge branch 'main' into feature/CCM-13475_send_print_events
simonlabarere d3a28ec
CCM-13475: Send print events
simonlabarere cbe7ee4
CCM-14347: Send Print config
simonlabarere 8533768
CCM-14347: Send Print config
simonlabarere e15f07c
CCM-14347: Send Print config
simonlabarere 8f90c56
CCM-14347: Send Print config
simonlabarere 1e6d3bf
CCM-14347: Send Print config
simonlabarere 7658aa1
CCM-14347: Send Print config
simonlabarere fd24d89
CCM-14347: Send Print config
simonlabarere 0d1807e
CCM-14347: Send Print config
simonlabarere 1c3bbee
CCM-14347: Send Print config
simonlabarere 4ba840b
Merge branch 'main' into feature/CCM-13475_send_print_events
lapenna-bjss abce4d7
CCM-13475: Remove package-lock.json file
lapenna-bjss 39a0605
CCM-13475: Test
lapenna-bjss 9fdee7a
CCM-13475: add input transformation
lapenna-bjss 48d8a4c
CCM-13475: pin @nhsdigital/nhs-notify-event-schemas-supplier-api to 1…
lapenna-bjss 47adec6
CCM-13475: add campaignId to letter prepared events
lapenna-bjss 266f4e3
CCM-13475: fix linter error
lapenna-bjss afa5e89
CCM-13475: address comments
lapenna-bjss 68c168d
Merge branch 'main' into feature/CCM-13475_send_print_events
lapenna-bjss 7c876f9
CCM-13475: resolve fast-xml-parser security vulnerability
lapenna-bjss c161303
CCM-13475: Add eslint-disable sonarjs/hardcoded-secret-signatures in …
lapenna-bjss 3aa0779
CCM-13475: Add max_receive_count to print-sender queue
lapenna-bjss 6a07f96
CCM-13475: Revert package-lock.json changes in docs/
lapenna-bjss 98357d3
CCM-13475: remove unused constant
lapenna-bjss d8cdf93
Merge branch 'main' into feature/CCM-13475_send_print_events
lapenna-bjss 5a19130
Merge branch 'main' into feature/CCM-13475_send_print_events
lapenna-bjss e6eb58e
CCM-13475: add statement condition
lapenna-bjss 0539218
CCM-13475: fix statement condition
lapenna-bjss bd36eda
CCM-13475: fix statement condition
lapenna-bjss 0283e7d
Merge branch 'main' into feature/CCM-13475_send_print_events
lapenna-bjss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
infrastructure/terraform/components/dl/cloudwatch_event_rule_letter_prepared.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| resource "aws_cloudwatch_event_rule" "letter_prepared" { | ||
| name = "${local.csi}-letter-prepared" | ||
| description = "Letter prepared event rule" | ||
| event_bus_name = aws_cloudwatch_event_bus.main.name | ||
|
|
||
| event_pattern = jsonencode({ | ||
| "detail" : { | ||
| "type" : [ | ||
| "uk.nhs.notify.letter-rendering.letter-request.prepared.v1" | ||
| ], | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_event_target" "letter-prepared-main-bus-target" { | ||
| rule = aws_cloudwatch_event_rule.letter_prepared.name | ||
| arn = module.eventpub.sns_topic.arn | ||
| event_bus_name = aws_cloudwatch_event_bus.main.name | ||
|
|
||
| input_path = "$.detail" | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
infrastructure/terraform/components/dl/cloudwatch_event_rule_pdf_analysed.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| resource "aws_cloudwatch_event_rule" "pdf_analysed" { | ||
| name = "${local.csi}-pdf-analysed" | ||
| description = "PDF Analysed event rule" | ||
| event_bus_name = aws_cloudwatch_event_bus.main.name | ||
|
|
||
| event_pattern = jsonencode({ | ||
| "detail" : { | ||
| "type" : [ | ||
| "uk.nhs.notify.digital.letters.print.pdf.analysed.v1" | ||
| ], | ||
| } | ||
| }) | ||
| } | ||
|
|
||
| resource "aws_cloudwatch_event_target" "pdf-analysed-print-sender-target" { | ||
| rule = aws_cloudwatch_event_rule.pdf_analysed.name | ||
| arn = module.sqs_print_sender.sqs_queue_arn | ||
| event_bus_name = aws_cloudwatch_event_bus.main.name | ||
| } |
10 changes: 10 additions & 0 deletions
10
infrastructure/terraform/components/dl/lambda_event_source_mapping_print_sender_lambda.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| resource "aws_lambda_event_source_mapping" "print_sender_lambda" { | ||
| event_source_arn = module.sqs_print_sender.sqs_queue_arn | ||
| function_name = module.print_sender.function_name | ||
| batch_size = var.queue_batch_size | ||
| maximum_batching_window_in_seconds = var.queue_batch_window_seconds | ||
|
|
||
| function_response_types = [ | ||
| "ReportBatchItemFailures" | ||
| ] | ||
| } |
88 changes: 88 additions & 0 deletions
88
infrastructure/terraform/components/dl/module_lambda_print_sender.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| module "print_sender" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip" | ||
|
|
||
| function_name = "print-sender" | ||
| description = "A function to trigger letter prints" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = local.component | ||
| environment = var.environment | ||
| project = var.project | ||
| region = var.region | ||
| group = var.group | ||
|
|
||
| log_retention_in_days = var.log_retention_in_days | ||
| kms_key_arn = module.kms.key_arn | ||
|
|
||
| iam_policy_document = { | ||
| body = data.aws_iam_policy_document.print_sender_lambda.json | ||
| } | ||
|
|
||
| function_s3_bucket = local.acct.s3_buckets["lambda_function_artefacts"]["id"] | ||
| function_code_base_path = local.aws_lambda_functions_dir_path | ||
| function_code_dir = "print-sender-lambda/dist" | ||
| function_include_common = true | ||
| handler_function_name = "handler" | ||
| runtime = "nodejs22.x" | ||
| memory = 128 | ||
| timeout = 60 | ||
| log_level = var.log_level | ||
|
|
||
| force_lambda_code_deploy = var.force_lambda_code_deploy | ||
| enable_lambda_insights = false | ||
|
|
||
| log_destination_arn = local.log_destination_arn | ||
| log_subscription_role_arn = local.acct.log_subscription_role_arn | ||
|
|
||
| lambda_env_vars = { | ||
| "EVENT_PUBLISHER_EVENT_BUS_ARN" = aws_cloudwatch_event_bus.main.arn | ||
| "EVENT_PUBLISHER_DLQ_URL" = module.sqs_event_publisher_errors.sqs_queue_url | ||
| "ENVIRONMENT" = var.environment | ||
| "ACCOUNT_TYPE" = var.aws_account_type | ||
| } | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "print_sender_lambda" { | ||
| statement { | ||
| sid = "PutEvents" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "events:PutEvents", | ||
| ] | ||
|
|
||
| resources = [ | ||
| aws_cloudwatch_event_bus.main.arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "SQSPermissionsPrintSenderQueue" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sqs:ReceiveMessage", | ||
| "sqs:DeleteMessage", | ||
| "sqs:GetQueueAttributes", | ||
| "sqs:GetQueueUrl", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.sqs_print_sender.sqs_queue_arn, | ||
| ] | ||
| } | ||
|
|
||
| statement { | ||
| sid = "SQSPermissionsEventPublisherDLQ" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "sqs:SendMessage", | ||
| "sqs:SendMessageBatch", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.sqs_event_publisher_errors.sqs_queue_arn, | ||
| ] | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
infrastructure/terraform/components/dl/module_sqs_print_sender.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| module "sqs_print_sender" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.30/terraform-sqs.zip" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = local.component | ||
| environment = var.environment | ||
| project = var.project | ||
| region = var.region | ||
| name = "print-sender" | ||
|
|
||
| sqs_kms_key_arn = module.kms.key_arn | ||
|
|
||
| visibility_timeout_seconds = 60 | ||
|
|
||
| create_dlq = true | ||
| max_receive_count = 1 | ||
gareth-allan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| sqs_policy_overload = data.aws_iam_policy_document.sqs_print_sender.json | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "sqs_print_sender" { | ||
| statement { | ||
| sid = "AllowEventBridgeToSendMessage" | ||
| effect = "Allow" | ||
|
|
||
| principals { | ||
| type = "Service" | ||
| identifiers = ["events.amazonaws.com"] | ||
| } | ||
|
|
||
| actions = [ | ||
| "sqs:SendMessage" | ||
| ] | ||
|
|
||
| resources = [ | ||
| "arn:aws:sqs:${var.region}:${var.aws_account_id}:${local.csi}-print-sender-queue" | ||
| ] | ||
gareth-allan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| condition { | ||
| test = "ArnEquals" | ||
| variable = "aws:SourceArn" | ||
| values = [aws_cloudwatch_event_rule.pdf_analysed.arn] | ||
| } | ||
| } | ||
| } | ||
61 changes: 61 additions & 0 deletions
61
infrastructure/terraform/components/dl/modules_eventpub.tf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| module "eventpub" { | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.30/terraform-eventpub.zip" | ||
|
|
||
| name = "eventpub" | ||
lapenna-bjss marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = var.component | ||
| environment = var.environment | ||
| project = var.project | ||
| region = var.region | ||
| group = var.group | ||
|
|
||
| default_tags = local.default_tags | ||
|
|
||
| kms_key_arn = module.kms.key_arn | ||
| log_retention_in_days = var.log_retention_in_days | ||
| log_level = var.log_level | ||
|
|
||
| force_destroy = var.force_destroy | ||
|
|
||
| event_cache_buffer_interval = 500 | ||
| enable_sns_delivery_logging = true | ||
| sns_success_logging_sample_percent = 0 | ||
|
|
||
| event_cache_expiry_days = 30 | ||
| enable_event_cache = true | ||
|
|
||
| data_plane_bus_arn = var.eventpub_data_plane_bus_arn | ||
| control_plane_bus_arn = var.eventpub_control_plane_bus_arn | ||
| } | ||
|
|
||
| resource "aws_sns_topic_policy" "eventbridge_publish" { | ||
| arn = module.eventpub.sns_topic.arn | ||
| policy = data.aws_iam_policy_document.sns_publish.json | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "sns_publish" { | ||
| statement { | ||
| sid = "AllowEventBridgePublish" | ||
| effect = "Allow" | ||
|
|
||
| principals { | ||
| type = "Service" | ||
| identifiers = ["events.amazonaws.com"] | ||
sidnhs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| actions = [ | ||
| "sns:Publish" | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.eventpub.sns_topic.arn | ||
| ] | ||
|
|
||
| condition { | ||
| test = "ArnEquals" | ||
| variable = "aws:SourceArn" | ||
| values = [aws_cloudwatch_event_rule.letter_prepared.arn] | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import { baseJestConfig } from '../../jest.config.base'; | ||
|
|
||
| const config = baseJestConfig; | ||
|
|
||
| export default config; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| { | ||
| "dependencies": { | ||
| "@nhsdigital/nhs-notify-event-schemas-letter-rendering": "^1.1.5", | ||
| "digital-letters-events": "^0.0.1", | ||
| "utils": "^0.0.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@tsconfig/node22": "^22.0.2", | ||
| "@types/aws-lambda": "^8.10.155", | ||
| "@types/jest": "^29.5.14", | ||
| "jest": "^29.7.0", | ||
| "typescript": "^5.9.3" | ||
| }, | ||
| "name": "nhs-notify-digital-letters-print-sender-lambda", | ||
| "private": true, | ||
| "scripts": { | ||
| "lambda-build": "rm -rf dist && npx esbuild --bundle --minify --sourcemap --target=es2020 --platform=node --loader:.node=file --entry-names=[name] --outdir=dist src/index.ts", | ||
| "lint": "eslint .", | ||
| "lint:fix": "eslint . --fix", | ||
| "test:unit": "jest", | ||
| "typecheck": "tsc --noEmit" | ||
| }, | ||
| "version": "0.0.1" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.