Skip to content

Commit

Permalink
fix: update iac
Browse files Browse the repository at this point in the history
  • Loading branch information
inaciogu committed Jan 19, 2024
1 parent 7764cc1 commit 329babd
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions iac/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,31 @@ provider "aws" {
}
}

locals {
queues = {
test = {
name = "test"
},
test2 = {
name = "test2"
},
test3 = {
name = "test3"
}
}
}

resource "aws_sqs_queue" "test" {
name = "test"
for_each = local.queues

name = each.value.name
}

resource "aws_sqs_queue_policy" "test" {
queue_url = aws_sqs_queue.test.id
policy = jsonencode({
for_each = local.queues

queue_url = aws_sqs_queue.test[each.key].id
policy = jsonencode({
Version = "2012-10-17"
Statement = [
{
Expand All @@ -28,7 +46,7 @@ resource "aws_sqs_queue_policy" "test" {
AWS = "*"
}
Action = "sqs:SendMessage"
Resource = aws_sqs_queue.test.arn
Resource = aws_sqs_queue.test[each.key].arn
Condition = {
ArnEquals = {
"aws:SourceArn" = aws_sns_topic.test.arn
Expand All @@ -44,7 +62,9 @@ resource "aws_sns_topic" "test" {
}

resource "aws_sns_topic_subscription" "test" {
for_each = local.queues

topic_arn = aws_sns_topic.test.arn
protocol = "sqs"
endpoint = aws_sqs_queue.test.arn
endpoint = aws_sqs_queue.test[each.key].arn
}

0 comments on commit 329babd

Please sign in to comment.