# ------------------------------------------------------------------------------
# Amazon SNS
# ------------------------------------------------------------------------------

resource "aws_sns_topic" "this" {
  name            = var.name
  delivery_policy = jsonencode(var.delivery)
}

resource "aws_sns_topic_subscription" "this" {
  count = length(var.emails)

  topic_arn = aws_sns_topic.this.arn
  protocol  = var.protocol
  endpoint  = var.emails[count.index]
}
