Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
variable "topics" {
default = ["new_users", "deleted_users"]
}
variable "environments" {
default = ["prod", "staging", "testing", "development]
}
for $topic in topics {
# Define SNS topics which are shared between all environments
resource "aws_sns_topic" "$topic.$env" { ... }
for $env in environments {
# Then for each topic define a queue for each env
resource "aws_sqs_queue" "$topic.$env-processors" { ... }
# And bind the created queue to its sns topic
resource "aws_sns_topic_subscription" "$topic.$env-to-$topic.$env-processors" {
topic_arn = "${aws_sns_topic.${topic.$env}.arn}"
endpoint = "${aws_sqs_queue.{$topic.$env-processors}.arn}"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment