-
Notifications
You must be signed in to change notification settings - Fork 4
VED:1099: Create Test SQS Queue for MNS #1268
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
Changes from all commits
10730f9
d236e98
8b54902
315ca08
e6a22c9
dcbde02
fc31344
6933833
55c18d3
e0c2134
337e745
0657096
8f8fc87
0520b95
163082a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| resource "aws_sqs_queue" "mns_test_notification" { | ||
| count = var.enable_mns_test_queue ? 1 : 0 | ||
| name = "${var.mns_test_notification_name_prefix}-queue" | ||
| fifo_queue = false | ||
| message_retention_seconds = 86400 | ||
| visibility_timeout_seconds = 300 | ||
| } | ||
|
|
||
|
|
||
| data "aws_iam_policy_document" "mns_test_notification_sqs_policy" { | ||
| count = var.enable_mns_test_queue ? 1 : 0 | ||
| statement { | ||
| sid = "mns-test-notification-allow-lambda-access" | ||
| effect = "Allow" | ||
|
|
||
| principals { | ||
| type = "AWS" | ||
| identifiers = [aws_iam_role.mns_publisher_lambda_exec_role.arn] | ||
|
dlzhry2nhs marked this conversation as resolved.
|
||
| } | ||
|
|
||
| actions = [ | ||
| "sqs:SendMessage", | ||
| ] | ||
|
|
||
| resources = [ | ||
| aws_sqs_queue.mns_test_notification[0].arn | ||
|
dlzhry2nhs marked this conversation as resolved.
|
||
| ] | ||
| } | ||
| } | ||
|
|
||
| resource "aws_sqs_queue_policy" "mns_test_notification_sqs" { | ||
| count = var.enable_mns_test_queue ? 1 : 0 | ||
| queue_url = aws_sqs_queue.mns_test_notification[0].id | ||
| policy = data.aws_iam_policy_document.mns_test_notification_sqs_policy[0].json | ||
| } | ||
|
|
||
| output "mns_test_queue_url" { | ||
| value = var.enable_mns_test_queue ? aws_sqs_queue.mns_test_notification[0].url : null | ||
| description = "URL of the MNS test notifications queue" | ||
| } | ||
|
|
||
| output "mns_test_queue_arn" { | ||
| value = var.enable_mns_test_queue ? aws_sqs_queue.mns_test_notification[0].arn : null | ||
| description = "ARN of the MNS test notifications queue" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,5 @@ | ||
| from typing import TypedDict | ||
|
|
||
| # Static constants for the MNS notification creation process | ||
| SPEC_VERSION = "1.0" | ||
| IMMUNISATION_TYPE = "imms-vaccinations-1" | ||
|
|
||
|
|
||
| # Fields from the incoming SQS message that forms part of the base schema and filtering attributes for MNS notifications | ||
| class FilteringData(TypedDict): | ||
| """MNS notification filtering attributes.""" | ||
|
|
||
| generalpractitioner: str | None | ||
| sourceorganisation: str | ||
| sourceapplication: str | ||
| subjectage: int | ||
| immunisationtype: str | ||
| action: str | ||
|
|
||
|
|
||
| class MnsNotificationPayload(TypedDict): | ||
| """CloudEvents-compliant MNS notification payload.""" | ||
|
|
||
| specversion: str | ||
| id: str | ||
| source: str | ||
| type: str | ||
| time: str | ||
| subject: str | ||
| dataref: str | ||
| filtering: FilteringData | ||
|
|
||
|
|
||
| DYNAMO_DB_TYPE_DESCRIPTORS = ("S", "N", "BOOL", "M", "L") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,12 @@ | |
|
|
||
| from common.api_clients.mns_service import MnsService | ||
| from common.api_clients.mns_setup import get_mns_service | ||
| from common.api_clients.mock_mns_service import MockMnsService | ||
| from common.clients import logger | ||
| from create_notification import create_mns_notification | ||
|
|
||
| mns_env = os.getenv("MNS_ENV", "int") | ||
| MNS_TEST_QUEUE_URL = os.getenv("MNS_TEST_QUEUE_URL") | ||
|
|
||
|
|
||
| def process_records(records: list[SQSMessage]) -> dict[str, list]: | ||
|
|
@@ -37,7 +39,7 @@ def process_records(records: list[SQSMessage]) -> dict[str, list]: | |
| return {"batchItemFailures": batch_item_failures} | ||
|
|
||
|
|
||
| def process_record(record: SQSMessage, mns_service: MnsService) -> None: | ||
| def process_record(record: SQSMessage, mns_service: MnsService | MockMnsService) -> None: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potentially even better if we implement an abstract class, or vanilla Python base class that defines the interface that includes a publish_notification(self, notification: MnsPayloadBla) -> None in the contract. Optional though, this is good enough for now...maybe. |
||
| """ | ||
| Process a single SQS record. | ||
| Args: | ||
|
|
@@ -65,8 +67,6 @@ def process_record(record: SQSMessage, mns_service: MnsService) -> None: | |
| mns_service.publish_notification(mns_notification_payload) | ||
| logger.info("Successfully created MNS notification", extra={"mns_notification_id": notification_id}) | ||
|
|
||
| return None | ||
|
|
||
|
|
||
| def extract_trace_ids(record: SQSMessage) -> Tuple[str, str | None]: | ||
| """ | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.