What does the formatting of multiple email addresses for the aws_sns_topic_subscription Terraform resource look like?
resource "aws_sns_topic_subscription" "target" {
topic_arn = aws_sns_topic.some_sns_topic.arn
protocol = "email"
endpoint = "[email protected],[email protected]"
}
I've tried many combinations for the endpoint parameter:
endpoint = "[email protected],[email protected]"
endpoint = "[email protected]", "[email protected]"
endpoint = ["[email protected]", "[email protected]"]
I've found nothing online or in the Terraform docs on how to do this. Thanks in advance.
endpoint accepts only one email address if the protocol is email type.
If you have multiple email addresses, you may want to use for_each to create a subscription for each address.
resource "aws_sns_topic_subscription" "target" {
for_each = toset(["[email protected]", "[email protected]"])
topic_arn = aws_sns_topic.some_sns_topic.arn
protocol = "email"
endpoint = each.value
}
This is what I have used so far:
locals {
emails = ["[email protected]", "[email protected]", "[email protected]"]
}
resource "aws_sns_topic_subscription" "target" {
count = length(local.emails)
topic_arn = aws_sns_topic.some_sns_topic.arn
protocol = "email"
endpoint = local.emails[count.index]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With