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
- Open the Amazon EventBridge console.
- From the Navigation menu, click
.
- On the Create rule window, complete the following steps:
- 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.
- 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.
- For Rule type, select Rule with an event
pattern.
- Click Next.
- For Event source, select AWS events or EventBridge
partner events.
- For Creation method, select Use pattern
form.
- In the Event pattern window, configure the event pattern by
completing the following steps:
- 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 |
- Click the Specific event(s) option and select Object
Created.
- Click Specific bucket(s) by name and enter the name of the
specific bucket that you want to collect events from.
- 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"
}]
}
}
}
- Click Add, then click
Next.
- Choose the SQS queue that you want to use as the target. Enter the name of the queue,
then click Next.
- On the Review and create page, click Create
rule.