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 = "aaa@gmail.com,bbb@gmail.com"
}
I've tried many combinations for the endpoint parameter:
endpoint = "aaa@gmail.com,bbb@gmail.com"
endpoint = "aaa@gmail.com", "bbb@gmail.com"
endpoint = ["aaa@gmail.com", "bbb@gmail.com"]
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(["aaa@gmail.com", "bbb@gmail.com"])
topic_arn = aws_sns_topic.some_sns_topic.arn
protocol = "email"
endpoint = each.value
}