Skip to content

Commit 315ca08

Browse files
committed
use queue url to trigger notification to SQS
1 parent 8b54902 commit 315ca08

5 files changed

Lines changed: 15 additions & 8 deletions

File tree

infrastructure/instance/mns_publisher.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module "mns_publisher" {
1111
imms_base_path = strcontains(var.sub_environment, "pr-") ? "immunisation-fhir-api/FHIR/R4-${var.sub_environment}" : "immunisation-fhir-api/FHIR/R4"
1212
lambda_kms_encryption_key_arn = data.aws_kms_key.existing_lambda_encryption_key.arn
1313
mns_publisher_resource_name_prefix = "${local.resource_scope}-mns-outbound-events"
14-
mns_test_notifcation_name_prefix = "${local.resource_scope}-mns-test-notification"
14+
mns_test_notification_name_prefix = "${local.resource_scope}-mns-test-notification"
1515
secrets_manager_policy_path = "${local.policy_path}/secret_manager.json"
1616
account_id = data.aws_caller_identity.current.account_id
1717
pds_environment = var.pds_environment

infrastructure/instance/modules/mns_publisher/sqs_test_publish_mns.tf

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Main queue for MNS notification testing
1+
# TODO: Remove when MNS platform authorizes imms-vaccinations-1 event type
2+
# Temporary SQS queue for testing MNS notifications until MNS HTTP endpoint is available
3+
24
resource "aws_sqs_queue" "mns_test_notification" {
3-
name = "${var.mns_test_notifcation_name_prefix}-queue"
5+
name = "${var.mns_test_notification_name_prefix}-queue"
46
fifo_queue = false
57
kms_master_key_id = aws_kms_key.mns_outbound_events.arn
68
visibility_timeout_seconds = 300

infrastructure/instance/modules/mns_publisher/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ variable "secrets_manager_policy_path" {
104104
description = "Path to the IAM policy JSON template for Secrets Manager access (e.g., ./policies/secret_manager.json)."
105105
}
106106

107-
variable "mns_test_notifcation_name_prefix" {
107+
variable "mns_test_notification_name_prefix" {
108108
type = string
109109
description = "The prefix for the name of resources for testing mns notification"
110110
}

lambdas/mns_publisher/src/mns_test_queue.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
sqs_client = boto3.client("sqs", region_name="eu-west-2")
1010

1111

12+
# TODO: Remove when MNS platform authorizes imms-vaccinations-1 event type
13+
# Temporary function to send MNS to SQS Queue for testing MNS notifications until MNS HTTP endpoint is available
1214
def send_notification_to_test_queue(mns_payload: dict) -> None:
1315
"""
1416
Send MNS notification payload to test SQS queue as fallback.

lambdas/mns_publisher/src/process_records.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from mns_test_queue import send_notification_to_test_queue
1212

1313
mns_env = os.getenv("MNS_ENV", "int")
14+
MNS_TEST_QUEUE_URL = os.getenv("MNS_TEST_QUEUE_URL")
1415

1516

1617
def process_records(records: list[SQSMessage]) -> dict[str, list]:
@@ -63,12 +64,14 @@ def process_record(record: SQSMessage, mns_service: MnsService) -> None:
6364
},
6465
)
6566

66-
try:
67+
# TODO: Remove when MNS platform authorizes imms-vaccinations-1 event type
68+
# Temporary SQS queue for testing MNS notifications until MNS HTTP endpoint is available
69+
if MNS_TEST_QUEUE_URL:
70+
send_notification_to_test_queue(mns_notification_payload)
71+
logger.info("Notification Successfully sent to SQS", extra={"notification_id": notification_id})
72+
else:
6773
mns_service.publish_notification(mns_notification_payload)
6874
logger.info("Successfully created MNS notification", extra={"mns_notification_id": notification_id})
69-
except Exception:
70-
send_notification_to_test_queue(mns_notification_payload)
71-
raise
7275

7376

7477
def extract_trace_ids(record: SQSMessage) -> Tuple[str, str | None]:

0 commit comments

Comments
 (0)