Events, Rules & Patterns

Read an event, then write a pattern that matches exactly the events you want.

1 min read

Every event has the same envelope. Here's what S3 sends when an object is created (after you turn on EventBridge notifications for the bucket):

JSON
{
  "source": "aws.s3",
  "detail-type": "Object Created",
  "region": "us-east-1",
  "detail": {
    "bucket": { "name": "notesnap-uploads" },
    "object": { "key": "notes/todo.txt", "size": 1024 }
  }
}

A rule's event pattern is JSON that looks like the parts you care about. Lists mean "any of these":

JSON
{
  "source": ["aws.s3"],
  "detail-type": ["Object Created"],
  "detail": {
    "bucket": { "name": ["notesnap-uploads"] },
    "object": { "key": [{ "prefix": "notes/" }] }
  }
}

This matches only new objects under notes/ in that bucket. Patterns also support suffix, anything-but, numeric ranges, exists, and more.

Targets

Each rule can send matching events to up to 5 targets. You can also transform the event with an input transformer before delivery, for example passing just the object key.

Tip

Turn on archive and replay for important buses. If a bug in a target drops events, you can replay the archived events once it's fixed.

Key takeaways

  • All events share an envelope: source, detail-type, detail, and more.
  • Patterns mirror the event's shape. Lists mean any-of, and operators like prefix refine matches.
  • Each rule fans out to up to 5 targets, and archives allow replay.

Check your understanding

Pick an answer to see the explanation.

  1. 1. In an event pattern, what does "source": ["aws.s3", "aws.ec2"] mean?