Tutorial: Creating an Amazon EventBridge rule that sends notifications to AWS Chatbot - AWS Chatbot

Tutorial: Creating an Amazon EventBridge rule that sends notifications to AWS Chatbot

AWS Chatbot currently supports notifications for most service events that are handled by Amazon EventBridge. When you create a rule for events, you tell EventBridge what action to take for events that match the rule. In this tutorial, you create a rule to use AWS Chatbot to generate an Amazon SNS topic notification that will appear in your Slack channel or Amazon Chime chatroom.

Note

AWS Chatbot only delivers notifications with their original EventBridge event message content to chat channels. If this message content is modified (such as by using EventBridge InputTransformers), AWS Chatbot won't be able to deliver notifications to your chat channels.

Tip

You might create an EventBridge rule that unintentionally sends too many notifications to your chat channels. This typically happens with EventBridge rules that trigger on API calls via AWS CloudTrail. To better control the number of notifications you generate, write your EventBridge rules with event pattern based filtering. For more information about EventBridge event patterns, see Content-based filtering in Amazon EventBridge event patterns in the EventBridge User Guide.

Prerequisites

For this tutorial, you need a Slack or Amazon Chime client for AWS Chatbot. For more information, see Getting started with AWS Chatbot in the AWS Chatbot Administrator Guide.

You also need to set up Amazon Simple Notification Service. Your Amazon SNS topic is used in the creation of your EventBridge rule and should be identical to the Amazon SNS topic used in your AWS Chatbot configuration. If you don't have any Amazon SNS topics yet, follow the steps in Getting Started with Amazon SNS in the Amazon Simple Notification Service Developer Guide.

For more information about EventBridge, see What Is Amazon EventBridge? in the EventBridge User Guide.

Create an Amazon EventBridge Rule

Receiving notifications about events of interest in your Slack channel or Amazon Chime chat room is a convenient way to monitor service processes. In this tutorial, you create an EventBridge rule to use AWS Chatbot to generate an Amazon SNS topic notification that will appear in your Slack channel or chat room. It is important to note that you only receive notifications from Amazon SNS topics that are used in your AWS Chatbot configuration.

To create an EventBridge rule

  1. Open the EventBridge console at https://console.aws.amazon.com/events/.

  2. In the navigation pane, choose Rules.

  3. Choose Create rule.

  4. Enter a name and description for the rule. A rule must have a unique name from other rules in the same Region.

  5. For Define pattern, choose Event Pattern.

  6. For Event matching pattern, choose Pre-defined pattern by service.

  7. For Service provider, choose AWS.

    Important

    Choosing All Events as your service provider can result in increased costs and notifications.

    Note

    Currently only AWS Services are supported.

  8. For Service name, choose the name of the service that emits the event.

  9. For Event type, choose the events you are interested in.

    Tip

    You can edit event patterns by choosing Edit and then choosing Save.

  10. In Select targets, set your Target as an SNS Topic.

  11. For Topic, choose the appropriate topic.

    Note

    This topic should be the same topic used in your AWS Chatbot configuration.

  12. (Optional) To add additional targets, choose Add target.

  13. Choose Create.

After the rule is created, you can view, edit, or delete it in the console under Rules. When an event occurs that matches the rule, you receive a notification in your Slack channel or Amazon Chime chat room from AWS Chatbot.

For information about testing your rule, see Test notifications from AWS services to Amazon Chime or Slack.

Receive Amazon EventBridge event notifications between AWS accounts and Regions

You can receive EventBridge event notifications between AWS accounts and Regions in your Slack channels and chat rooms using one AWS Chatbot and one Amazon SNS topic. To do this, use the Amazon SNS topic in your AWS Chatbot configuration as the target for your receiver account's EventBridge rule. With this mechanism, you don’t have to configure AWS Chatbot in each AWS account you want to receive notifications from. If you have multiple accounts with multiple resources you want to monitor, you can configure AWS Chatbot in one account and have all other accounts send their events to the account with AWS Chatbot using EventBridge. For more information about sending and receiving events across accounts and Regions, see Sending and receiving EventBridge events between AWS accounts and Regions in the Amazon EventBridge User Guide.

Delete an Amazon EventBridge rule

You can remove any resources created for this tutorial by navigating to the EventBridge console and deleting the resource.

To delete or disable an EventBridge rule