Amazon S3 Event Notifications with Amazon EventBridge

Amazon S3 Event Notifications with Amazon EventBridge

Clock Icon2022.10.26

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

Recently, i have tried to create a rule in the EventBridge console that sends events to SNS topic when Amazon S3 Object Created events are received. You can also send email notifications when Amazon S3 objects are created using Amazon EventBridge and Amazon SNS.

Create S3 Bucket

  • Let’s create the S3 bucket.
    • Go to the Amazon S3 Console. Enter the Bucket Name. In this example "s3-eventbridge-notification".
    • Keep the other setting as default and Create the Bucket.
  • Go the Properties section of the bucket which has been created.
  • Navigate to the Event Notifications section and find the Amazon EventBridge subsection. Click on Edit.
  • In the "Send notifications to Amazon EventBridge for all events in this bucket". Choose ON. To receive Amazon S3 events in EventBridge, it is necessary to enable EventBridge in the Amazon S3 console.

Create An Amazon SNS Topic

  • Open the Amazon SNS console.
  • In the navigation pane, choose Topics.
  • Click on Create topic. For Type, choose Standard.
  • Enter Name of the Topic. Finally , click Create Topic.

Create An Amazon SNS Subscription

Create a subscription to get email notifications from Amazon S3 when events are received by the topic.

  • In the navigation pane, choose Subscriptions and Click on Create Subscription.
  • For Topic ARN, choose the topic which has been created.
  • For Protocol, choose Email.
  • For Endpoint, enter your email address.
  • Click on Create subscription.

  • Check the Email receive from AWS notifications. Confirm the subscription by choosing Confirm subscription in the email receive from AWS notifications.

  • Subscription Confirmed !

  • Let's check the status of the subscription. If Status of the subscription is Confirmed then you have successfully subscribed.

Create A Rule In Eventbridge

Create a rule to send events to SNS topic when an Amazon S3 object is created.

  • Go to the Amazon EventBridge console and Choose Create rule

Step 1 :

  • In the Define rule detail.
    • Enter the "Name" of the rule. In this example, s3-notification-test.
    • For Rule type, Select Rule with an event pattern.

Step 2

  • In the Build event pattern.
    • Select AWS events or Eventbridge partner events as Event Source from which events are sent.
    • Click on Next.
  • Navigate to the Event Pattern section. Do the following settings.
    • For Event source, Choose AWS services.
    • For AWS Service, Simple Storage Service(S3)
    • 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 Specific bucket(s) by name and Choose the S3 bucket which has been created before. In this example, select s3-eventbridge-notification.
    • Check the Event pattern displayed on right side.
    • Click on Next.

Step 3

  • In the Select target(s).
    • For Target types, choose AWS service.
    • For Select a target, choose SNS topic from the drop-down list.
    • For Topic, select the SNS topic which has been created before. In this example, select sns-topic-test.
    • Click on Next.

Step 4

  • In the Tags(optional). You can assign a label(tag) to AWS resource.

Step 5

  • In the Review and create. Review the details of the rule and Click on Create rule.
  • Check the Event pattern section to see the event.

  • Check the Target section to see the Targets.

Test

  • Let’s create an Amazon S3 object by uploading a file to an EventBridge-enabled bucket. In this example, "s3-eventbridge-notification"

  • Wait a few minutes and verify if you receive an email from AWS notifications.

Conclusion

In this blog i have created a rule in the EventBridge console that sends events to SNS topic when Amazon S3 Object Created events are received. You can also set up a rule to invoke a AWS Lambda function on a schedule. I hope you have find this blog helpful.

References

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.