Skip to content

Commit a126d09

Browse files
committed
Try this
1 parent cd78578 commit a126d09

4 files changed

Lines changed: 18 additions & 41 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
resource "aws_lambda_event_source_mapping" "supplier_events_forwarder" {
2+
event_source_arn = module.supplier_events_queue.sqs_queue_arn
3+
function_name = module.supplier_events_forwarder_lambda.function_arn
4+
batch_size = 10
5+
function_response_types = [
6+
"ReportBatchItemFailures"
7+
]
8+
}

infrastructure/terraform/components/api/module_sqs_letter_updates.tf

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,6 @@ module "sqs_letter_updates" {
1818

1919
data "aws_iam_policy_document" "letter_updates_queue_policy" {
2020
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}-letter-updates-queue"
36-
]
37-
38-
condition {
39-
test = "ArnEquals"
40-
variable = "aws:SourceArn"
41-
values = [module.eventsub.sns_topic.arn]
42-
}
43-
}
44-
4521
statement {
4622
sid = "AllowSNSPermissions"
4723
effect = "Allow"

infrastructure/terraform/components/api/module_sqs_supplier_events_queue.tf

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ module "supplier_events_queue" {
1616
sqs_policy_overload = data.aws_iam_policy_document.supplier_events_queue_policy.json
1717
}
1818

19-
data "aws_iam_policy_document" "supplier_events_queue_policy" {
19+
data "aws_iam_policy_document" "letter_updates_queue_policy" {
2020
version = "2012-10-17"
2121
statement {
22-
sid = "AllowSNSToSendSupplierEvents"
22+
sid = "AllowSNSPermissions"
2323
effect = "Allow"
2424

2525
principals {
@@ -28,17 +28,22 @@ data "aws_iam_policy_document" "supplier_events_queue_policy" {
2828
}
2929

3030
actions = [
31-
"sqs:SendMessage"
31+
"sqs:SendMessage",
32+
"sqs:ListQueueTags",
33+
"sqs:GetQueueUrl",
34+
"sqs:GetQueueAttributes",
3235
]
3336

3437
resources = [
35-
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${var.project}-${var.environment}-${var.component}-supplier-events-queue"
38+
"arn:aws:sqs:${var.region}:${var.aws_account_id}:${var.project}-${var.environment}-${var.component}-letter-updates-queue"
3639
]
3740

3841
condition {
3942
test = "ArnEquals"
4043
variable = "aws:SourceArn"
41-
values = [module.eventsub.sns_topic_clone.arn]
44+
values = [
45+
module.eventsub.sns_topic_clone.arn
46+
]
4247
}
4348
}
4449
}

infrastructure/terraform/components/api/sns_topic_subscription_supplier_events_forwarder_lambda.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,3 @@ resource "aws_sns_topic_subscription" "supplier_events_queue" {
44
endpoint = module.supplier_events_queue.sqs_queue_arn
55
raw_message_delivery = false
66
}
7-
8-
resource "aws_lambda_event_source_mapping" "supplier_events_forwarder" {
9-
event_source_arn = module.supplier_events_queue.sqs_queue_arn
10-
function_name = module.supplier_events_forwarder_lambda.function_arn
11-
batch_size = 10
12-
scaling_config { maximum_concurrency = 10 }
13-
14-
depends_on = [
15-
module.supplier_events_queue,
16-
module.supplier_events_forwarder_lambda
17-
]
18-
}

0 commit comments

Comments
 (0)