Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/c4/notifhir/viewer/callback/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ is_not_draft: false
last_modified_date: 2026-03-26
owner: Ross Buggins
author: Tom D'Roza
diagrams: [c4code-nhsapp-status-handler]
diagrams: [c4code-core-status-handler]
events-raised: [viewer-digital-letter-read]
events-consumed: []
c4type: code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---

title: c4code-nhsapp-status-handler
title: c4code-core-status-handler

---

```mermaid
architecture-beta
group AppStatusHandler(cloud)[NHSAppStatusHandler]
group AppStatusHandler(cloud)[CoreStatusHandler]
service optedOutEvent(aws:res-amazon-eventbridge-event)[channel status PUBLISHED v1 Event]
service lambda(logos:aws-lambda)[App Status Handler] in AppStatusHandler
service sqs(logos:aws-sqs)[App Status Queue] in AppStatusHandler
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/terraform/components/dl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ No requirements.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_core_notifier"></a> [core\_notifier](#module\_core\_notifier) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_core_status_handler"></a> [core\_status\_handler](#module\_core\_status\_handler) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_eventpub"></a> [eventpub](#module\_eventpub) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-eventpub.zip | n/a |
| <a name="module_file_scanner"></a> [file\_scanner](#module\_file\_scanner) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_kms"></a> [kms](#module\_kms) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-kms.zip | n/a |
Expand All @@ -76,7 +77,6 @@ No requirements.
| <a name="module_mesh_download"></a> [mesh\_download](#module\_mesh\_download) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_mesh_poll"></a> [mesh\_poll](#module\_mesh\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_move_scanned_files"></a> [move\_scanned\_files](#module\_move\_scanned\_files) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_nhsapp_status_handler"></a> [nhsapp\_status\_handler](#module\_nhsapp\_status\_handler) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_pdm_mock"></a> [pdm\_mock](#module\_pdm\_mock) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_pdm_poll"></a> [pdm\_poll](#module\_pdm\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
| <a name="module_pdm_uploader"></a> [pdm\_uploader](#module\_pdm\_uploader) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip | n/a |
Expand All @@ -95,11 +95,11 @@ No requirements.
| <a name="module_s3bucket_reporting"></a> [s3bucket\_reporting](#module\_s3bucket\_reporting) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-s3bucket.zip | n/a |
| <a name="module_s3bucket_static_assets"></a> [s3bucket\_static\_assets](#module\_s3bucket\_static\_assets) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-s3bucket.zip | n/a |
| <a name="module_sqs_core_notifier"></a> [sqs\_core\_notifier](#module\_sqs\_core\_notifier) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_core_status_handler"></a> [sqs\_core\_status\_handler](#module\_sqs\_core\_status\_handler) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_event_publisher_errors"></a> [sqs\_event\_publisher\_errors](#module\_sqs\_event\_publisher\_errors) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_mesh_acknowledge"></a> [sqs\_mesh\_acknowledge](#module\_sqs\_mesh\_acknowledge) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_mesh_download"></a> [sqs\_mesh\_download](#module\_sqs\_mesh\_download) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_move_scanned_files"></a> [sqs\_move\_scanned\_files](#module\_sqs\_move\_scanned\_files) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_nhsapp_status_handler"></a> [sqs\_nhsapp\_status\_handler](#module\_sqs\_nhsapp\_status\_handler) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_pdm_poll"></a> [sqs\_pdm\_poll](#module\_sqs\_pdm\_poll) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_pdm_uploader"></a> [sqs\_pdm\_uploader](#module\_sqs\_pdm\_uploader) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
| <a name="module_sqs_print_analyser"></a> [sqs\_print\_analyser](#module\_sqs\_print\_analyser) | https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip | n/a |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ resource "aws_cloudwatch_event_rule" "channel_status_published" {
})
}

resource "aws_cloudwatch_event_target" "sqs_nhsapp_status_handler_target" {
resource "aws_cloudwatch_event_target" "channel_status_published_core_status_handler" {
rule = aws_cloudwatch_event_rule.channel_status_published.name
arn = module.sqs_nhsapp_status_handler.sqs_queue_arn
arn = module.sqs_core_status_handler.sqs_queue_arn
event_bus_name = aws_cloudwatch_event_bus.main.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "aws_cloudwatch_event_rule" "message_status_published" {
name = "${local.csi}-message-status-published"
description = "message status PUBLISHED event rule"
event_bus_name = aws_cloudwatch_event_bus.main.name

event_pattern = jsonencode({
"detail" : {
"type" : [
"uk.nhs.notify.message.status.PUBLISHED.v1"
],
}
})
}

resource "aws_cloudwatch_event_target" "message_status_published_core_status_handler" {
rule = aws_cloudwatch_event_rule.message_status_published.name
arn = module.sqs_core_status_handler.sqs_queue_arn
event_bus_name = aws_cloudwatch_event_bus.main.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "aws_lambda_event_source_mapping" "core_status_handler" {
event_source_arn = module.sqs_core_status_handler.sqs_queue_arn
function_name = module.core_status_handler.function_name
batch_size = var.queue_batch_size
maximum_batching_window_in_seconds = var.queue_batch_window_seconds

function_response_types = [
"ReportBatchItemFailures"
]
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module "nhsapp_status_handler" {
module "core_status_handler" {
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.0.6/terraform-lambda.zip"

function_name = "nhsapp-status-handler"
description = "A function for handling NHS app status"
function_name = "core-status-handler"
description = "A function for handling core status"

aws_account_id = var.aws_account_id
component = local.component
Expand All @@ -15,12 +15,12 @@ module "nhsapp_status_handler" {
kms_key_arn = module.kms.key_arn

iam_policy_document = {
body = data.aws_iam_policy_document.nhsapp_status_handler.json
body = data.aws_iam_policy_document.core_status_handler.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 = "nhsapp-status-handler/dist"
function_code_dir = "core-status-handler/dist"
function_include_common = true
handler_function_name = "handler"
runtime = "nodejs22.x"
Expand All @@ -43,13 +43,14 @@ module "nhsapp_status_handler" {
}
}

data "aws_iam_policy_document" "nhsapp_status_handler" {
data "aws_iam_policy_document" "core_status_handler" {
statement {
sid = "AllowTtlDynamoAccess"
effect = "Allow"

actions = [
"dynamodb:UpdateItem",
"dynamodb:DeleteItem",
]

resources = [
Expand All @@ -72,7 +73,7 @@ data "aws_iam_policy_document" "nhsapp_status_handler" {
}

statement {
sid = "SQSPermissionsNhsappStatusHandlerQueue"
sid = "SQSPermissionsCoreStatusHandlerQueue"
effect = "Allow"

actions = [
Expand All @@ -83,7 +84,7 @@ data "aws_iam_policy_document" "nhsapp_status_handler" {
]

resources = [
module.sqs_nhsapp_status_handler.sqs_queue_arn,
module.sqs_core_status_handler.sqs_queue_arn,
]
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
module "sqs_nhsapp_status_handler" {
module "sqs_core_status_handler" {
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/3.1.4/terraform-sqs.zip"

aws_account_id = var.aws_account_id
component = local.component
environment = var.environment
project = var.project
region = var.region
name = "nhsapp-status-handler"
name = "core-status-handler"
sqs_kms_key_arn = module.kms.key_arn
visibility_timeout_seconds = var.sqs_visibility_timeout_seconds
create_dlq = true
max_receive_count = var.sqs_max_receive_count
sqs_policy_overload = data.aws_iam_policy_document.sqs_nhsapp_status_handler.json
sqs_policy_overload = data.aws_iam_policy_document.sqs_core_status_handler.json
}

data "aws_iam_policy_document" "sqs_nhsapp_status_handler" {
data "aws_iam_policy_document" "sqs_core_status_handler" {
statement {
sid = "AllowEventBridgeToSendMessage"
effect = "Allow"
Expand All @@ -29,13 +29,16 @@ data "aws_iam_policy_document" "sqs_nhsapp_status_handler" {
]

resources = [
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${local.csi}-nhsapp-status-handler-queue"
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${local.csi}-core-status-handler-queue"
]

condition {
test = "ArnLike"
variable = "aws:SourceArn"
values = [aws_cloudwatch_event_rule.channel_status_published.arn]
values = [
aws_cloudwatch_event_rule.channel_status_published.arn,
aws_cloudwatch_event_rule.message_status_published.arn
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"jest": "^29.7.0",
"typescript": "^5.9.3"
},
"name": "nhs-notify-digital-letters-nhsapp-status-handler",
"name": "nhs-notify-digital-letters-core-status-handler",
"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",
Expand Down
Loading
Loading