-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpolicies.tf
42 lines (32 loc) · 922 Bytes
/
policies.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
resource "aws_sqs_queue_policy" "policy" {
for_each = local.sqs_queues
queue_url = data.aws_sqs_queue.queues[each.key].id
policy = data.aws_iam_policy_document.queue_policy[each.key].json
depends_on = [
module.sqs_queues,
]
}
data "aws_iam_policy_document" "queue_policy" {
for_each = local.sqs_queues
dynamic "statement" {
for_each = local.sqs_queues[each.key].topics_to_subscribe
content {
effect = "Allow"
actions = ["sqs:SendMessage"]
principals {
type = "*"
identifiers = ["*"]
}
resources = [
data.aws_sqs_queue.queues[each.key].arn,
]
condition {
test = "ArnEquals"
variable = "aws:SourceArn"
values = [
local.topics_subscriptions[var.fifo ? "${each.key}_${statement.value.name}.fifo" : "${each.key}_${statement.value.name}"].topic_arn,
]
}
}
}
}