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
| Variable | Type | Description |
|---|---|---|
sns_topic_name | string | The name of the SNS topic to create |
slack_webhook_url | string | The URL of your Slack incoming webhook |
slack_channel | string | The name of the Slack channel for notifications |
slack_username | string | The username that will appear on Slack messages |
Steps
Set up a Slack incoming webhook
Create an incoming webhook in your Slack workspace:
- Go to https://my.slack.com/services/new/incoming-webhook/.
- Select the channel where you want notifications to appear.
- Click Add Incoming WebHooks Integration.
- Copy the Webhook URL — you will use it in the next step.
Add the module to your Terraform configuration
Add the following block to your Terraform configuration, replacing the placeholder values with your own:
Initialize and apply
Run the following commands to provision the resources:Terraform creates an SNS topic, a Lambda function, and the subscription that connects them.