Forwarding ObjectCreated notifications to the SQS queue by using Amazon EventBridge

Create an Amazon EventBridge rule to forward ObjectCreated notifications to a target SQS queue.

Before you begin

Before you can create a rule in Amazon EventBridge, you must enable Amazon EventBridge on your AWS Management console. For more information, see Enabling Amazon EventBridge.

Procedure

  1. Open the Amazon EventBridge console.
  2. From the Navigation menu, click Rules > Create rule.
  3. On the Create rule window, complete the following steps:
    1. Enter a name and description for the rule.
      Important: A rule can't have the same name as another rule that is both in the same region and on the same event bus.
    2. For Event bus, select the event bus that you want to associate with this rule. If you select AWS default event bus, the rule matches the events that come from your account.
    3. For Rule type, select Rule with an event pattern.
  4. Click Next.
  5. For Event source, select AWS events or EventBridge partner events.
  6. For Creation method, select Use pattern form.
  7. In the Event pattern window, configure the event pattern by completing the following steps:
    1. Select the values listed in the table for the following parameters:
      Parameter Value
      Event source AWS services
      AWS service Simple Storage Service (S3)
      Event type Amazon S3 Event Notification
    2. Click the Specific event(s) option and select Object Created.
    3. Click Specific bucket(s) by name and enter the name of the specific bucket that you want to collect events from.
    4. Optional: To enable notifications for a specific folder prefix or file extension, choose Custom pattern (JSON editor) instead of Use pattern form for the creation method, and create your custom event pattern.
      For example, this event pattern filters for Object Created events in your bucket. In this example, example/directory is the directory prefix and .png is the suffix.
      {
        "source": ["aws.s3"],
        "detail-type": ["Object Created"],
        "detail": {
          "bucket": {
            "name": ["<example-bucket>"]
          },
          "object": {
            "key": [{
              "prefix": "example/directory/"
            }],
            "key": [{
              "suffix": ".png"
            }]
          }
        }
      }
    5. Click Add, then click Next.
  8. Choose the SQS queue that you want to use as the target. Enter the name of the queue, then click Next.
  9. On the Review and create page, click Create rule.