Skip to content

Instantly share code, notes, and snippets.

@garo
Created August 31, 2016 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save garo/974113c6d1f056973efdb8357ceb7e96 to your computer and use it in GitHub Desktop.
Save garo/974113c6d1f056973efdb8357ceb7e96 to your computer and use it in GitHub Desktop.
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