Tutorial: Send an email when events happen using Amazon EventBridge
You can send email notifications when Amazon Simple Storage Service
(Amazon S3) objects are created using Amazon EventBridge and Amazon SNS. In this tutorial, you will create an SNS
topic and subscription. Then, you will create a rule in the
EventBridge console that sends events to that topic when Amazon S3
Object Created
events are received.
Steps:
Prerequisites
To recieve Amazon S3 events in EventBridge, you must enable EventBridge in the Amazon S3 console. This tutorial assumes EventBridge is enabled. For more information, see Enabling Amazon EventBridge in the S3 console.
Step 1: Create an Amazon SNS topic
Create a topic to receive the events from EventBridge.
To create a topic
Open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home
. -
In the navigation pane, choose Topics.
-
Choose Create topic.
-
For Type, choose Standard.
-
Enter
eventbridge-test
as the name of the topic. -
Choose Create topic.
Step 2: Create an Amazon SNS subscription
Create a subscription to get email notifications from Amazon S3 when events are received by the topic.
To create a subscription
Open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home
. -
In the navigation pane, choose Subscriptions.
-
Choose Create subscription.
-
For Topic ARN, choose the topic you created in step 1. For this tutorial, choose eventbridge-test.
-
For Protocol, choose Email.
-
For Endpoint, enter your email address.
-
Choose Create subscription.
-
Confirm the subscription by choosing Confirm subscription in the email you receive from AWS notifications.
Step 3: Create a rule
Create a rule to send events to your topic when an Amazon S3 object is created.
To create a rule
Open the Amazon EventBridge console at https://console.aws.amazon.com/events/
. -
In the navigation pane, choose Rules.
-
Choose Create rule.
-
Enter a name and description for the rule. For example, name the rule
s3-test
-
For Event bus, select default.
-
For Rule type, choose Rule with an event pattern.
-
Choose Next.
-
For Event source, choose AWS events or EventBridge partner events.
-
For Creation method, choose Use pattern form.
-
For Event pattern, do the following:
-
For Event source, select AWS services from the drop-down list.
-
For AWS service, select Simple Storage Service (S3) from the drop-down list.
-
For Event type, choose Amazon S3 Event Notification from the drop-down list.
-
Choose Specific events(s) and choose Object Created from the drop-down list.
-
Choose Any bucket
-
-
Choose Next.
-
For Target types, choose AWS service.
-
For Select a target, choose SNS topic from the drop-down list.
-
For Topic, select the Amazon SNS topic that you created in the Step 1: Create an SNS topic section. In this example, select
eventbridge-test
. -
Choose Next.
-
Choose Next.
-
Review the details of the rule and choose Create rule.
Step 4: Test the rule
To test your rule, create an Amazon S3 object by uploading a file to an EventBridge-enabled bucket. Then, wait a few minutes and verify if you receive an email from AWS notifications.
Step 5: Clean up your resources
You can now delete the resources that you created for this tutorial, unless you want to retain them. By deleting AWS resources that you are no longer using, you prevent unnecessary charges to your AWS account.
To delete the SNS topic
-
Open the Topics page
of the SNS console. -
Select the topic that you created.
-
Choose Delete.
-
Enter
delete me
. -
Choose Delete.
To delete the SNS subscription
-
Open the Subscriptions page
of the SNS console. -
Select the subscription that you created.
-
Choose Delete.
-
Choose Delete.
To delete the EventBridge rule(s)
-
Open the Rules page
of the EventBridge console. -
Select the rule(s) that you created.
-
Choose Delete.
-
Choose Delete.