Question

Difficulty: MediumStream Processing and Event Routing with Amazon Kinesis and EventBridge

A retail application publishes clickstream events to a custom Amazon EventBridge event bus. A developer needs to route a subset of these events (where the `event_type` is either `add_to_cart` or `checkout`) to an Amazon Kinesis Data Stream for real-time analytics. The event payload includes `session_id` (a UUID v4), `user_id`, and `event_type`. The Kinesis Data Stream has 12 shards. Which configuration should the developer implement to route the correct events while ensuring even data distribution across all stream shards?

  1. A
    Configure an EventBridge rule to route the events to an Amazon SQS queue that triggers a Kinesis producer Lambda function, and configure the SQS queue's visibility timeout to be lower than the Lambda function's timeout.
  2. B
    Configure an EventBridge rule with the event pattern `{"detail": {"event_type": ["add_to_cart", "checkout"]}}`. Set the target as the Kinesis Data Stream, and configure the partition key path to use `$.detail.event_type`.
  3. Configure an EventBridge rule with the event pattern `{"detail": {"event_type": ["add_to_cart", "checkout"]}}`. Set the target as the Kinesis Data Stream, and configure the partition key path to use `$.detail.session_id`.Answer
  4. D
    Configure an EventBridge rule to route all events to a custom Lambda function that forwards events to Kinesis. Deploy the Lambda function in a private VPC subnet without configuring a NAT Gateway or VPC endpoint.

Answer

Configure an EventBridge rule filtering for the specific event types and route them to Kinesis using the session ID as the partition key.
The correct configuration uses EventBridge's declarative event filtering to only route the matching event types, and uses the high-entropy session ID as the partition key to ensure uniform shard distribution.

Step-by-Step Solution

1
Analyze the EventBridge routing filter pattern.
Only events with `event_type` matching `add_to_cart` or `checkout` should be routed.
This filters the traffic at the event bus level before reaching the target stream.
2
Evaluate the partition key strategy for Kinesis Data Stream shards.
Use `.detail.sessionidinsteadof.detail.session_id` instead of `.detail.event_type`.
The Kinesis partition key dictates shard assignment. A UUID-based key provides high entropy and uniform distribution across the 12 shards, whereas a low-entropy key like event type will bottle-neck traffic onto a maximum of two shards.

Key Concept

Selecting high-entropy partition keys for Kinesis Data Streams and setting EventBridge event pattern filters.
Rate this question