generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
CCM-14200 - event driven callback delivery #33
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
mjewildnhs
merged 87 commits into
main
from
feature/CCM-14200-event-driven-callback-delivery
Mar 4, 2026
Merged
Changes from all commits
Commits
Show all changes
87 commits
Select commit
Hold shift + click to select a range
5ca2d2f
WIP - US1 tasks
mjewildnhs 7c665e4
WIP - US1 tasks - mock webhook
mjewildnhs e71af5b
WIP - US1 tasks - mock webhook - infrastructure
mjewildnhs 0ed242a
DROP - temporarily lower coverage
mjewildnhs da9a62e
Event schema changes
mjewildnhs 5a91489
DROP - Update fast-xml-parser
mjewildnhs 9dfe2bb
Sonar fixes
mjewildnhs 93411e2
Update agent file to run correct test command
mjewildnhs ab366a2
Exclude jest config from coverage
mjewildnhs b9e1198
Metric test coverage
mjewildnhs ed1268c
Logger and error handler coverage
mjewildnhs ea76bc6
Handle SQS event correctly in lambda
mjewildnhs 29c4834
Permit lambda to put cloudwatch metrics
mjewildnhs 7e4d36a
DROP - temp test client
mjewildnhs 40fd823
explicitly set pull-request read permission
cgitim 88830b9
WIP - type fixes
mjewildnhs 927ffb8
Tidy up transform lambda code
mjewildnhs 3d502c0
AGENTS.md add section on comment policy
mjewildnhs 32b1d68
Simplify validation using zod
mjewildnhs 2addb1d
Remove superflous comments, simplify code
mjewildnhs c7c7da8
WIP - re-write metrics
mjewildnhs 42f23ea
Re-write metrics to use aws-embedded-metrics
mjewildnhs 606e023
WIP - concurrent event processing
mjewildnhs f45e0e9
More cleanup
mjewildnhs 97ff2fe
Refactor error handling and callback logging
mjewildnhs bdb613b
Transform lambda root handler test coverage
mjewildnhs 0cef9fa
Introduce base test config
mjewildnhs eb2ca52
Sonar and jest vscode settings
mjewildnhs efeabc6
Remove extraneous int test comments
mjewildnhs 67c6a01
Refactor some of the int test to use await util
mjewildnhs 2b1ef67
Tidy up unncessary arg in unit test script and remove unncessary tsco…
mjewildnhs 97e3dc9
Scripts for running int test
mjewildnhs 3852e8f
Remove dependencies not needed now int tests own workspace
mjewildnhs 5314faf
Refactor lambda handler code out
mjewildnhs 99ca53f
Refactor lambda to tidy up observablity
mjewildnhs 342dcee
Revert "explicitly set pull-request read permission"
mjewildnhs 1e2488d
Swap todo for comment for snar
mjewildnhs e2c1ca3
Update zod/pino and update validation test assertions
mjewildnhs a197309
DI for handler and more test coverage
mjewildnhs 04d2981
Use mock pino in mock lambda test
mjewildnhs be8912e
Fix cloudwatch events - single dimension with env, other fields as pr…
mjewildnhs b5f15ab
Fix event pipe template to align with lambda output
mjewildnhs 6cc1be9
Remove dataschemaversion from event pipe input template and bus rule
mjewildnhs 2bebb59
Var for pipe log level
mjewildnhs 75daff9
Remove event parameters which don't work in batch scenario
mjewildnhs ea4095d
Fix correlation ID on delivery initiated event/logging
mjewildnhs b9954e1
Permissions on lambda to allow it to be invoked without IAM
mjewildnhs 789937a
Log the received payload in the mock lambda
mjewildnhs b3cb32e
Fix validation and correlation id
mjewildnhs 609074a
Fix DLQ permission
mjewildnhs 9036cdb
Ensure node_modules excluded from test coverage
mjewildnhs 6f4ded0
Regen package-lock.json
mjewildnhs cbdb6de
Use new model package
mjewildnhs d0959f4
Fix issues from model changes
mjewildnhs 4c91a25
Fix non dev dependencies in in tests
mjewildnhs 293153b
Add retry policy to event bus rules
mjewildnhs bec40a2
Use package models in int tests and mock lambda
mjewildnhs 4970864
Add verify script for lint, typecheck, tests
mjewildnhs 4276689
Fix event name and source values
mjewildnhs 3c2fd92
Update integration test to publish to SQS not shared event bus
mjewildnhs 0138508
Turn off client creation
mjewildnhs cfd4654
Review feedback: remove unncessary terraform comments
mjewildnhs a1a8c50
Review feedback: remove unnecessary object keys
mjewildnhs 6a97ec6
Reconfigure coverage thresholds
mjewildnhs 088d25d
Update node tool version to fix lint warn
mjewildnhs da84030
Ignore int test helpers from coverage check
mjewildnhs 4cfff69
Remove invoke lambda function permission from mock callback
mjewildnhs 97ba0f0
Fix getQueueMessageCount ignoring in-flight SQS messages (#45)
Copilot 71f4998
Verify channel status callback received in in test
mjewildnhs 3a814a7
fixup! Fix getQueueMessageCount ignoring in-flight SQS messages (#45)
mjewildnhs 5191893
Fix hardcoded region in int test
mjewildnhs 9be0dac
Revert "Tidy up unncessary arg in unit test script and remove unncess…
mjewildnhs 48be4bf
DROP: Revert "Turn off client creation"
mjewildnhs 31af10b
Rename metrics namespace and remove redundant comment
mjewildnhs e2d0639
Revert "Remove invoke lambda function permission from mock callback"
mjewildnhs 54f2a7b
Simplify mock lambda data handling and correct correlationID
mjewildnhs 92b2cd9
Assert x-api-key in mock lambda and generate it randomly
mjewildnhs d184493
fixup! Assert x-api-key in mock lambda and generate it randomly
mjewildnhs 3658527
Refactor unit tests in transform lambda
mjewildnhs 790e14b
Remove superfluous tests and retry/config load errors
mjewildnhs 9edd1f0
Simplify mock event in mock lambda test
mjewildnhs b623a32
Remove superfluous paths from int test tsconfig
mjewildnhs be082d5
Remove superfluous terraform outputs
mjewildnhs 5393bdc
fixup! Fix DLQ permission
mjewildnhs 5fd1aa9
Rename test-client -> mock-client
mjewildnhs df9874f
Turn off mock client creation
mjewildnhs dfed24a
Switch terraform module source URL format
mjewildnhs 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
Some comments aren't visible on the classic Files Changed page.
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
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
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
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
2 changes: 1 addition & 1 deletion
2
infrastructure/terraform/components/callbacks/module_client_destination.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
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
97 changes: 97 additions & 0 deletions
97
infrastructure/terraform/components/callbacks/module_mock_webhook_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,97 @@ | ||
| module "mock_webhook_lambda" { | ||
| count = var.deploy_mock_webhook ? 1 : 0 | ||
| source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.29/terraform-lambda.zip" | ||
|
|
||
| function_name = "mock-webhook" | ||
| description = "Mock webhook endpoint for integration testing - logs received callbacks to CloudWatch" | ||
|
|
||
| aws_account_id = var.aws_account_id | ||
| component = var.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.mock_webhook_lambda[0].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 = "mock-webhook-lambda/dist" | ||
| function_include_common = true | ||
| handler_function_name = "handler" | ||
| runtime = "nodejs22.x" | ||
| memory = 256 | ||
| timeout = 10 | ||
| 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 = { | ||
| LOG_LEVEL = var.log_level | ||
| API_KEY = random_password.mock_webhook_api_key[0].result | ||
| } | ||
| } | ||
|
|
||
| resource "random_password" "mock_webhook_api_key" { | ||
| count = var.deploy_mock_webhook ? 1 : 0 | ||
| length = 32 | ||
| special = false | ||
| } | ||
|
|
||
| data "aws_iam_policy_document" "mock_webhook_lambda" { | ||
| count = var.deploy_mock_webhook ? 1 : 0 | ||
|
|
||
| statement { | ||
| sid = "KMSPermissions" | ||
| effect = "Allow" | ||
|
|
||
| actions = [ | ||
| "kms:Decrypt", | ||
| "kms:GenerateDataKey", | ||
| ] | ||
|
|
||
| resources = [ | ||
| module.kms.key_arn, | ||
| ] | ||
| } | ||
| } | ||
|
|
||
| # Lambda Function URL for mock webhook (test/dev only) | ||
| resource "aws_lambda_function_url" "mock_webhook" { | ||
| count = var.deploy_mock_webhook ? 1 : 0 | ||
| function_name = module.mock_webhook_lambda[0].function_name | ||
| authorization_type = "NONE" # Public endpoint for testing | ||
|
|
||
| cors { | ||
| allow_origins = ["*"] | ||
| allow_methods = ["POST"] | ||
| allow_headers = ["*"] | ||
| max_age = 86400 | ||
| } | ||
| } | ||
|
|
||
| resource "aws_lambda_permission" "mock_webhook_function_url" { | ||
| count = var.deploy_mock_webhook ? 1 : 0 | ||
| statement_id = "FunctionURLAllowPublicAccess" | ||
| action = "lambda:InvokeFunctionUrl" | ||
| function_name = module.mock_webhook_lambda[0].function_name | ||
| principal = "*" | ||
| function_url_auth_type = "NONE" | ||
| } | ||
|
|
||
| resource "aws_lambda_permission" "mock_webhook_function_invoke" { | ||
| count = var.deploy_mock_webhook ? 1 : 0 | ||
| statement_id = "FunctionURLAllowInvokeAction" | ||
| action = "lambda:InvokeFunction" | ||
| function_name = module.mock_webhook_lambda[0].function_name | ||
| principal = "*" | ||
| } |
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
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
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
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.