Skip to content

Commit dabcdec

Browse files
committed
VED-79: Unsubscribe at teardown and make mns_url dynamic
1 parent e9c94b7 commit dabcdec

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

azure/azure-pr-teardown-pipeline.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,19 @@ jobs:
5252
make init && make destroy aws_account_no=${account_id} environment=$(WORKSPACE)
5353
displayName: Destroy terraform PR workspace and linked resources
5454
retryCountOnTaskFailure: 2
55+
56+
- bash: |
57+
export AWS_PROFILE=apim-dev
58+
pyenv install -s 3.11.11
59+
pyenv local 3.11.11
60+
poetry env use 3.11
61+
poetry install --no-root
62+
63+
export PYTHONPATH=$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/mns_subscription
64+
65+
echo "Deleting SQS Subscription from MNS..."
66+
poetry run python src/unsubscribe_mns.py
67+
displayName: "Delete MNS Subscription"
68+
workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/mns_subscription"
69+
env:
70+
SQS_ARN: "$(ID_SYNC_QUEUE_ARN)"

mns_subscription/src/mns_service.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@
1313
)
1414

1515
SQS_ARN = os.getenv("SQS_ARN")
16-
MNS_URL = "https://int.api.service.nhs.uk/multicast-notification-service/subscriptions"
16+
17+
apigee_env = os.getenv("APIGEE_ENVIRONMENT", "int")
18+
MNS_URL = "https://api.service.nhs.uk/multicast-notification-service/subscriptions" \
19+
if apigee_env == "prod" else "https://int.api.service.nhs.uk/multicast-notification-service/subscriptions"
1720

1821

1922
class MnsService:
@@ -45,6 +48,7 @@ def subscribe_notification(self) -> dict | None:
4548

4649
print(f"Access Token: {self.access_token}")
4750
print(f"SQS ARN: {SQS_ARN}")
51+
print(f"MNS_URL: {MNS_URL}")
4852
print(f"Headers: {self.request_headers}")
4953
print(f"Payload: {json.dumps(self.subscription_payload, indent=2)}")
5054

0 commit comments

Comments
 (0)