From 329babdc039b9a66ca185e8a4dd471a9ff191cbf Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 19 Jan 2024 09:17:34 -0300 Subject: [PATCH] fix: update iac --- iac/terraform/main.tf | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/iac/terraform/main.tf b/iac/terraform/main.tf index d7681b2..2ab72c0 100644 --- a/iac/terraform/main.tf +++ b/iac/terraform/main.tf @@ -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 = [ { @@ -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 @@ -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 } \ No newline at end of file