Skip to content

Commit e0c2134

Browse files
committed
enable test queue only in dev
1 parent 55c18d3 commit e0c2134

11 files changed

Lines changed: 27 additions & 10 deletions

File tree

infrastructure/instance/environments/dev/internal-dev/variables.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ environment = "dev"
22
immunisation_account_id = "345594581768"
33
dspp_core_account_id = "603871901111"
44
pds_environment = "int"
5+
enable_mns_test_queue = true
56
mns_environment = "int"
67
error_alarm_notifications_enabled = true
78
create_mesh_processor = false

infrastructure/instance/environments/dev/internal-qa/variables.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ environment = "dev"
22
immunisation_account_id = "345594581768"
33
dspp_core_account_id = "603871901111"
44
pds_environment = "int"
5+
enable_mns_test_queue = true
56
mns_environment = "int"
67
error_alarm_notifications_enabled = false
78
mns_publisher_feature_enabled = true

infrastructure/instance/environments/dev/pr/variables.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ environment = "dev"
22
immunisation_account_id = "345594581768"
33
dspp_core_account_id = "603871901111"
44
pds_environment = "int"
5+
enable_mns_test_queue = true
56
mns_environment = "int"
67
error_alarm_notifications_enabled = false
78
mns_publisher_feature_enabled = true # Switch this off once tested fully e2e in Lambda branch

infrastructure/instance/environments/dev/ref/variables.tfvars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ environment = "dev"
22
immunisation_account_id = "345594581768"
33
dspp_core_account_id = "603871901111"
44
pds_environment = "ref"
5+
enable_mns_test_queue = true
56
mns_environment = "int"
67
error_alarm_notifications_enabled = true
78
create_mesh_processor = false

infrastructure/instance/mns_publisher.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module "mns_publisher" {
1414
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
17+
enable_mns_test_queue = var.enable_mns_test_queue
1718
pds_environment = var.pds_environment
1819
mns_environment = var.mns_environment
1920

infrastructure/instance/modules/mns_publisher/mns_publisher_lambda.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ resource "aws_lambda_function" "mns_publisher_lambda" {
192192
environment {
193193
variables = {
194194
SPLUNK_FIREHOSE_NAME = var.splunk_firehose_stream_name
195-
MNS_TEST_QUEUE_URL = aws_sqs_queue.mns_test_notification.url
195+
MNS_TEST_QUEUE_URL = aws_sqs_queue.mns_test_notification[1].url
196196
IMMUNIZATION_ENV = var.resource_scope,
197197
IMMUNIZATION_BASE_PATH = var.imms_base_path
198198
PDS_ENV = var.pds_environment

infrastructure/instance/modules/mns_publisher/sqs_test_publish_mns.tf

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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-
41
resource "aws_sqs_queue" "mns_test_notification" {
2+
count = var.enable_mns_test_queue ? 1 : 0
53
name = "${var.mns_test_notification_name_prefix}-queue"
64
fifo_queue = false
75
message_retention_seconds = 86400
@@ -24,23 +22,23 @@ data "aws_iam_policy_document" "mns_test_notification_sqs_policy" {
2422
]
2523

2624
resources = [
27-
aws_sqs_queue.mns_test_notification.arn
25+
aws_sqs_queue.mns_test_notification[0].arn
2826
]
2927
}
3028
}
3129

3230
resource "aws_sqs_queue_policy" "mns_test_notification_sqs" {
33-
queue_url = aws_sqs_queue.mns_test_notification.id
31+
queue_url = aws_sqs_queue.mns_test_notification[0].id
3432
policy = data.aws_iam_policy_document.mns_test_notification_sqs_policy.json
3533
}
3634

3735
output "mns_test_queue_url" {
38-
value = aws_sqs_queue.mns_test_notification.url
36+
value = aws_sqs_queue.mns_test_notification[0].url
3937
description = "URL of the MNS test notifications queue"
4038
}
4139

4240
output "mns_test_queue_arn" {
43-
value = aws_sqs_queue.mns_test_notification.arn
41+
value = aws_sqs_queue.mns_test_notification[0].arn
4442
description = "ARN of the MNS test notifications queue"
4543
}
4644

infrastructure/instance/modules/mns_publisher/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,10 @@ variable "secrets_manager_policy_path" {
107107
variable "mns_test_notification_name_prefix" {
108108
type = string
109109
description = "The prefix for the name of resources for testing mns notification"
110+
}
111+
112+
variable "enable_mns_test_queue" {
113+
description = "Enable test SQS queue for MNS notifications (dev only)"
114+
type = bool
115+
default = false
110116
}

infrastructure/instance/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ variable "mns_publisher_feature_enabled" {
9797
type = bool
9898
}
9999

100+
variable "enable_mns_test_queue" {
101+
description = "Enable test SQS queue for MNS notifications (dev only)"
102+
type = bool
103+
default = false
104+
}
105+
100106
variable "has_sub_environment_scope" {
101107
description = "True if the sub-environment is a standalone environment, e.g. internal-dev. False if it is part of a blue-green split, e.g. int-green."
102108
type = bool

lambdas/shared/src/common/api_clients/mock_mns_service.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import json
2+
import os
23

34
import boto3
45

56
from common.clients import logger
67

8+
REGION_NAME = os.getenv("AWS_REGION", "eu-west-2")
9+
710

811
class MockMnsService:
912
def __init__(self, queue_url):
@@ -12,7 +15,7 @@ def __init__(self, queue_url):
1215
logger.info(f"MockMnsService initialized with queue: {queue_url}")
1316

1417
def _get_sqs_client(self):
15-
return boto3.client("sqs", region_name="eu-west-2")
18+
return boto3.client("sqs", region_name=REGION_NAME)
1619

1720
def publish_notification(self, mns_payload: dict) -> None:
1821
"""

0 commit comments

Comments
 (0)