Package Exports
- notifier-slack-sns
- notifier-slack-sns/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (notifier-slack-sns) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Notifier - A notification system via Slack and AWS SNS
Features
- Send message to SNS topic or Slack notification webhook
- Notification failure cross check. If SNS or Slack notification is failed to send, error notification will be sent to another channel
- Supports sns-to-slack-publisher lambda service, which forwards the SNS message to designated slack channel
Initialization
const Notifier = require('notifier-slack-sns');
Notifier.initialize({
region: YOUR_AWS_REGION,
sns_topic: YOUR_DEFAULT_SNS_TOPIC,
slack_api_url: YOUR_DEFAULT_SLACK_WEBHOOK_URL,
slack_channel_id: YOUR_SLACK_CHANNEL_ID,
slack_sns_topic: YOUR_SNS_TOPIC_CONNECTED_TO_SNS_TO_SLACK_PUBLISHER,
error_sns_topic: YOUR_SYSTEM_ERROR_SNS_TOPIC,
error_slack_url: YOUR_SYSTEM_ERROR_SLACK_URL,
error_msg_prefix: YOUR_SYSTEM_ERROR_MESSAGE
});region: AWS region string (required) E.g.,us-west-2sns_topic: SNS topic arn stringslack_api_url: Slack webhook urlslack_channel_id: Slack channel id (required if using sns-to-slack-publisher lambda service)slack_sns_topic: Arn string of SNS topic which connects to sns-to-slack-publisher lambda (required if using sns-to-slack-publisher lambda service)error_sns_topic: Arn string of SNS topic which is used for sending system error messageerror_slack_url: Arn string of slack webhook url which is used for sending system error messageerror_msg_prefix: Prefix of the system error message
How to Use
// Send SNS message
//
await sendSNS("your sns subject", "your sns message");
// Send Slack message
//
await sendSlack("your slack message");
// Send Slack message via SNS
//
await snsToSlack("your slack message");
// Send error message to both Slack and SNS
//
await Notifier.sendSystemErrorMsg("all", error.message || JSON.stringify(error));Note
- Slack incoming webhook setup - https://api.slack.com/messaging/webhooks
- In order to use
snsToSlack(), you will need to setup your ownsns-to-slack-publisherlambda service which can forward the SNS message to Slack channel