Skip to content

Commit be12e80

Browse files
authored
VED-874: MNS subscription fixes for prod release. (#939)
* VED-874: Create a single MNS queue in preprod and prod. Allow creating MNS subscriptions in prod. * VED-874: Always subscribe using the int MNS environment.
1 parent b10bff5 commit be12e80

File tree

5 files changed

+15
-9
lines changed

5 files changed

+15
-9
lines changed

.github/workflows/deploy-backend.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ jobs:
137137
if: ${{ inputs.environment == 'dev' && inputs.create_mns_subscription }}
138138
working-directory: "./lambdas/mns_subscription"
139139
env:
140+
APIGEE_ENVIRONMENT: int
140141
SQS_ARN: ${{ env.ID_SYNC_QUEUE_ARN }}
141142
run: |
142143
poetry install --no-root

infrastructure/instance/id_sync_lambda.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ resource "aws_iam_policy" "id_sync_lambda_exec_policy" {
181181
"sqs:DeleteMessage",
182182
"sqs:GetQueueAttributes"
183183
],
184-
Resource = "arn:aws:sqs:eu-west-2:${var.immunisation_account_id}:${local.short_prefix}-id-sync-queue"
184+
Resource = aws_sqs_queue.id_sync_queue.arn
185185
},
186186
# NB anomaly: in redis_sync this appears in "redis_sync_lambda_kms_access_policy"
187187
{
@@ -313,8 +313,8 @@ resource "aws_cloudwatch_log_group" "id_sync_log_group" {
313313

314314
# NEW
315315
resource "aws_lambda_event_source_mapping" "id_sync_sqs_trigger" {
316-
event_source_arn = "arn:aws:sqs:eu-west-2:${var.immunisation_account_id}:${local.short_prefix}-id-sync-queue"
317-
function_name = aws_lambda_function.id_sync_lambda.arn # TODO
316+
event_source_arn = aws_sqs_queue.id_sync_queue.arn
317+
function_name = aws_lambda_function.id_sync_lambda.arn
318318

319319
# Optional: Configure batch size and other settings
320320
batch_size = 10

infrastructure/instance/sqs_id_sync.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_sqs_queue" "id_sync_queue" {
2-
name = "${local.short_prefix}-id-sync-queue"
2+
name = "imms-${local.resource_scope}-id-sync-queue"
33
kms_master_key_id = data.aws_kms_key.existing_id_sync_sqs_encryption_key.arn
44
visibility_timeout_seconds = 360
55
redrive_policy = jsonencode({
@@ -9,7 +9,7 @@ resource "aws_sqs_queue" "id_sync_queue" {
99
}
1010

1111
resource "aws_sqs_queue" "id_sync_dlq" {
12-
name = "${local.short_prefix}-id-sync-dlq"
12+
name = "imms-${local.resource_scope}-id-sync-dlq"
1313
}
1414

1515
resource "aws_sqs_queue_redrive_allow_policy" "id_sync_queue_redrive_allow_policy" {

lambdas/mns_subscription/src/subscribe_mns.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import logging
2+
import os
23

34
from mns_setup import get_mns_service
45

6+
apigee_env = os.getenv("APIGEE_ENVIRONMENT", "int")
7+
58

69
def run_subscription():
7-
mns = get_mns_service()
10+
mns = get_mns_service(mns_env=apigee_env)
811
return mns.check_subscription()
912

1013

lambdas/mns_subscription/src/unsubscribe_mns.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import logging
2+
import os
23

34
from mns_setup import get_mns_service
45

6+
apigee_env = os.getenv("APIGEE_ENVIRONMENT", "int")
7+
58

69
def run_unsubscribe():
7-
mns = get_mns_service()
8-
result = mns.check_delete_subscription()
9-
return result
10+
mns = get_mns_service(mns_env=apigee_env)
11+
return mns.check_delete_subscription()
1012

1113

1214
if __name__ == "__main__":

0 commit comments

Comments
 (0)