Skip to content

Commit 00d3096

Browse files
committed
Use SNS topi filters instead of two different topics
1 parent f965a36 commit 00d3096

4 files changed

Lines changed: 64 additions & 19 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Queue to transport letter status amendment messages
2+
module "amendments_queue" {
3+
source = "https://github.com/NHSDigital/nhs-notify-shared-modules/releases/download/v2.0.24/terraform-sqs.zip"
4+
5+
name = "amendments_queue"
6+
7+
aws_account_id = var.aws_account_id
8+
component = var.component
9+
environment = var.environment
10+
project = var.project
11+
region = var.region
12+
13+
sqs_kms_key_arn = module.kms.key_arn
14+
15+
create_dlq = true
16+
sqs_policy_overload = data.aws_iam_policy_document.amendments_queue_policy.json
17+
}
18+
19+
data "aws_iam_policy_document" "amendments_queue_policy" {
20+
version = "2012-10-17"
21+
statement {
22+
sid = "AllowSNSToSendMessage"
23+
effect = "Allow"
24+
25+
principals {
26+
type = "Service"
27+
identifiers = ["sns.amazonaws.com"]
28+
}
29+
30+
actions = [
31+
"sqs:SendMessage"
32+
]
33+
34+
resources = [
35+
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${var.project}-${var.environment}-${var.component}-amendments_queue-queue"
36+
]
37+
38+
condition {
39+
test = "ArnEquals"
40+
variable = "aws:SourceArn"
41+
values = [module.eventsub.sns_topic.arn]
42+
}
43+
}
44+
}

infrastructure/terraform/components/api/module_sqs_letter_status_updates.tf

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
resource "aws_sns_topic_subscription" "eventsub_sqs_amendments" {
2+
topic_arn = module.eventsub.sns_topic.arn
3+
protocol = "sqs"
4+
endpoint = module.amendments_queue.sqs_queue_arn
5+
raw_message_delivery = true
6+
7+
filter_policy_scope = "MessageBody"
8+
filter_policy = jsonencode({
9+
type = [{ prefix = "uk.nhs.notify.supplier-api.letter" }]
10+
})
11+
}
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
resource "aws_sns_topic_subscription" "eventsub_sqs_letter_updates" {
2-
topic_arn = module.eventsub.sns_topic.arn
3-
protocol = "sqs"
4-
endpoint = module.sqs_letter_updates.sqs_queue_arn
2+
topic_arn = module.eventsub.sns_topic.arn
3+
protocol = "sqs"
4+
endpoint = module.sqs_letter_updates.sqs_queue_arn
5+
raw_message_delivery = true
6+
7+
filter_policy_scope = "MessageBody"
8+
filter_policy = jsonencode({
9+
type = [{ prefix = "uk.nhs.notify.letter-rendering.letter-request.prepared" }]
10+
})
511
}

0 commit comments

Comments
 (0)