Hi, I’m trying to declare a few SQS queues, SNS topic and subscriptions in a single step, but unable to establish how I can pass the SQS queue ARNs to the subscription step:
provider “aws” {
region = “eu-west-1”
}
resource “aws_sqs_queue” “sqs_queue” {
for_each = toset(var.sqs_queue)
name = each.value
}
resource “aws_sns_topic” “sns_topic” {
name = “myTopic”
}
resource “aws_sns_topic_subscription” “sns_topic_subscription” {
for_each = toset(var.sqs_queue)
topic_arn = aws_sns_topic.sns_topic.arn
protocol = “sqs”
endpoint = aws_sqs_queue.sqs_queue[???]
}
If anyone with more experience, and understanding of Terraform, who can give me some pointers I’d appreciate it, as reading about index, element etc. is not producing a working solution. TIA.