Skip to main content
This guide walks you through deploying the terraform-aws-modules/notify-slack/aws module, which creates an SNS topic and a Lambda function that forwards messages to a Slack channel via an incoming webhook.

Required variables

VariableTypeDescription
sns_topic_namestringThe name of the SNS topic to create
slack_webhook_urlstringThe URL of your Slack incoming webhook
slack_channelstringThe name of the Slack channel for notifications
slack_usernamestringThe username that will appear on Slack messages
Treat slack_webhook_url as a secret. Anyone with this URL can post messages to your Slack channel. Store it in a secrets manager or encrypt it with KMS rather than committing it to version control. See Securing the webhook URL for details.

Steps

1

Set up a Slack incoming webhook

Create an incoming webhook in your Slack workspace:
  1. Go to https://my.slack.com/services/new/incoming-webhook/.
  2. Select the channel where you want notifications to appear.
  3. Click Add Incoming WebHooks Integration.
  4. Copy the Webhook URL — you will use it in the next step.
2

Add the module to your Terraform configuration

Add the following block to your Terraform configuration, replacing the placeholder values with your own:
module "notify_slack" {
  source  = "terraform-aws-modules/notify-slack/aws"
  version = "~> 7.0"

  sns_topic_name = "slack-topic"

  slack_webhook_url = "https://hooks.slack.com/services/AAA/BBB/CCC"
  slack_channel     = "aws-notification"
  slack_username    = "reporter"
}
3

Initialize and apply

Run the following commands to provision the resources:
terraform init
terraform plan
terraform apply
Terraform creates an SNS topic, a Lambda function, and the subscription that connects them.
After terraform apply completes, run terraform output slack_topic_arn to retrieve the ARN of the SNS topic. You will need it to publish test messages and to configure other AWS services to send alerts.
4

Test by publishing a message to the SNS topic

Publish a test message to confirm that notifications reach your Slack channel:
aws sns publish \
  --topic-arn $(terraform output -raw slack_topic_arn) \
  --message "Test notification from terraform-aws-notify-slack"
Within a few seconds you should see the message appear in the Slack channel you configured.

Build docs developers (and LLMs) love