terraform-aws-sns-lambda-notify-slack icon indicating copy to clipboard operation
terraform-aws-sns-lambda-notify-slack copied to clipboard

Ability to create multiple SNS topics, each to a different slack channel

Open wesleung opened this issue 2 years ago • 0 comments

Have a question? Please checkout our Slack Community or visit our Slack Archive.

Slack Community

Describe the Feature

Ability to define multiple SNS topics, each sending to different slack channels. Problem when I do this with the current implementation on the second pass of the loop we get a log group duplicate error: ╷ │ Error: creating CloudWatch Logs Log Group (/aws/lambda/XXX-YYYYYY-default): ResourceAlreadyExistsException: The specified log group already exists │ │ with module.notify_slack["b"].module.notify_slack.aws_cloudwatch_log_group.lambda[0], │ on .terraform/modules/notify_slack.notify_slack/main.tf line 46, in resource "aws_cloudwatch_log_group" "lambda": │ 46: resource "aws_cloudwatch_log_group" "lambda" { │ ╵

Expected Behavior

List or Map of SNS topic to slack channels in a for_each loop to work properly

Use Case

SNS Topics:

  • "slack-a" sns topic sends to slack channel "#a"
  • "slack-b" sns topic sends to slack channel "#b"

Describe Ideal Solution

A clear and concise description of what you want to happen. If you don't know, that's okay. ` variable "slack_channel" { description = "List of slack channels" type = list default = ["a", "b"] }

module "notify_slack" { for_each = toset(var.slack_channel) source = "git::https://github.com/cloudposse/terraform-aws-sns-lambda-notify-slack?ref=tags/0.5.9" namespace = var.account_name name = "slack-${each.key}" slack_channel = each.key slack_webhook_url = var.slack_webhook_url slack_username = var.slack_username `

Alternatives Considered

Additional Context

This issue looks to be a problem with the underlying terraform-aws-modules/notify-slack/aws module

wesleung avatar Jan 24 '23 22:01 wesleung