File tree Expand file tree Collapse file tree
infrastructure/terraform/components/api Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ module "supplier_allocator" {
1515 kms_key_arn = module. kms . key_arn
1616
1717 iam_policy_document = {
18- body = data.aws_iam_policy_document.sqs_supplier_allocator_lambda .json
18+ body = data.aws_iam_policy_document.supplier_allocator_lambda .json
1919 }
2020
2121 function_s3_bucket = local. acct . s3_buckets [" lambda_function_artefacts" ][" id" ]
@@ -40,7 +40,7 @@ module "supplier_allocator" {
4040 })
4141}
4242
43- data "aws_iam_policy_document" "sqs_supplier_allocator_lambda " {
43+ data "aws_iam_policy_document" "supplier_allocator_lambda " {
4444 statement {
4545 sid = " KMSPermissions"
4646 effect = " Allow"
Original file line number Diff line number Diff line change @@ -12,5 +12,60 @@ module "sqs_supplier_allocator" {
1212
1313 visibility_timeout_seconds = 60
1414
15- create_dlq = true
15+ create_dlq = true
16+ sqs_policy_overload = data. aws_iam_policy_document . supplier_allocator_queue_policy . json
17+ }
18+
19+ data "aws_iam_policy_document" "supplier_allocator_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 } -supplier-allocator-queue"
36+ ]
37+
38+ condition {
39+ test = " ArnEquals"
40+ variable = " aws:SourceArn"
41+ values = [module . eventsub . sns_topic . arn ]
42+ }
43+ }
44+
45+ statement {
46+ sid = " AllowSNSPermissions"
47+ effect = " Allow"
48+
49+ principals {
50+ type = " Service"
51+ identifiers = [" sns.amazonaws.com" ]
52+ }
53+
54+ actions = [
55+ " sqs:SendMessage" ,
56+ " sqs:ListQueueTags" ,
57+ " sqs:GetQueueUrl" ,
58+ " sqs:GetQueueAttributes" ,
59+ ]
60+
61+ resources = [
62+ " arn:aws:sqs:${ var . region } :${ var . aws_account_id } :${ var . project } -${ var . environment } -${ var . component } -supplier-allocator-queue"
63+ ]
64+
65+ condition {
66+ test = " ArnEquals"
67+ variable = " aws:SourceArn"
68+ values = [module . eventsub . sns_topic . arn ]
69+ }
70+ }
1671}
You can’t perform that action at this time.
0 commit comments