provider "aws" {
  region = "us-east-1"
}

terraform {
  backend "s3" {
    bucket  = "orcd-terraform-state"
    key     = "prod/swf-feed-ingestion/sns/terraform.tfstate"
    region  = "us-east-1"
    encrypt = "true"
  }
}

module "swf_feed_ingestion_sns" {
  source = "git@github.com:theorchard/terraform-sns.git//?ref=1.1.4"

  environment        = var.environment
  sns_topic_name     = var.sns_topic
  application_family = var.application_family
}

resource "aws_sns_topic_subscription" "topic_email_subscription" {
  count     = length(local.emails)
  topic_arn = module.swf_feed_ingestion_sns.topic_arn
  protocol  = "email"
  endpoint  = local.emails[count.index]
}
