Tutorial: Send a notification when an Amazon S3 object is created - Amazon EventBridge

Tutorial: Send a notification when an Amazon S3 object is created

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.

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

  1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home.

  2. In the navigation pane, choose Topics.

  3. Choose Create topic.

  4. For Type, choose Standard.

  5. Enter eventbridge-test as the name of the topic.

  6. 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

  1. Open the Amazon SNS console at https://console.aws.amazon.com/sns/v3/home.

  2. In the navigation pane, choose Subscriptions.

  3. Choose Create subscription.

  4. For Topic ARN, choose the topic you created in step 1. For this tutorial, choose eventbridge-test.

  5. For Protocol, choose Email.

  6. For Endpoint, enter your email address.

  7. Choose Create subscription.

  8. 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

  1. Open the Amazon 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. For example, name the rule s3-test

  5. For Event bus, select default.

  6. For Rule type, choose Rule with an event pattern.

  7. Choose Next.

  8. For Event source, choose AWS services.

  9. For Event pattern, do the following:

    1. For Event source, select Simple Storage Service (S3) from the drop-down list.

    2. For Event type, choose Amazon S3 Event Notification from the drop-down list.

    3. Choose Specific events(s) and choose Object Created from the drop-down list.

    4. Choose Any bucket

  10. Choose Next.

  11. For Target types, choose AWS service.

  12. For Select a target, choose SNS topic from the drop-down list.

  13. For Topic, select the Kinesis stream that you created in the Step 1: Create an SNS topic section. In this example, select eventbridge-test.

  14. Choose Next.

  15. Choose Next.

  16. 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

  1. Open the Topics page of the SNS console.

  2. Select the topic that you created.

  3. Choose Delete.

  4. Enter delete me.

  5. Choose Delete.

To delete the SNS subscription

  1. Open the Subscriptions page of the SNS console.

  2. Select the subscription that you created.

  3. Choose Delete.

  4. Choose Delete.

To delete the EventBridge rule(s)

  1. Open the Rules page of the EventBridge console.

  2. Select the rule(s) that you created.

  3. Choose Delete.

  4. Choose Delete.