Fun with Learning Technology
LearnCoursesQuestionsTracksToolsNewsExplorePractice
Fun with Learning Technology

A new problem, explained clearly, every day.

Subscribe
Learn
  • Lessons
  • Topics
  • News
  • Tools
  • Courses
  • Career tracks
  • Everything
Site
  • About
  • Contact
  • Support
  • Privacy
  • Terms
Get the daily one

One email per new problem. No spam.

Request a tutorial

Requests shape what gets made next.

© 2026 Fun with Learning TechnologyRSS
Home›Courses›AWS›EventBridge

Messaging

EventBridge

Amazon EventBridge is a serverless event bus that acts as a central nervous system for decoupled microservices by routing events between sources and targets. It enables asynchronous communication patterns that eliminate the need for hard-coded dependencies, drastically improving system scalability and resilience. You should reach for EventBridge whenever you need to orchestrate complex workflows across distributed systems or trigger actions based on real-time changes in your AWS environment.

The Event Bus Architecture

At its core, EventBridge operates on a publish-subscribe model, fundamentally decoupling the producer of an event from its consumer. Unlike point-to-point messaging, the producer does not need to know where the event is going or how it will be processed. It simply emits a structured JSON object to the event bus. The bus serves as an intelligent router that evaluates every incoming event against a set of user-defined rules. Because the bus handles the delivery logistics, developers can introduce new consumer services without modifying the original code of the event producer. This architecture is essential for building modular systems where components evolve independently. By decoupling through an event bus, you gain the ability to scale your system components horizontally and ensure that a failure in one service does not cascade through the entire architecture, providing inherent fault isolation and operational stability.

# Example of putting an event onto the default bus using AWS CLI
aws events put-events --entries '[{
  "Source": "order.service",
  "DetailType": "OrderCreated",
  "Detail": "{\"orderId\": \"12345\", \"total\": 99.99}",
  "EventBusName": "default"
}]'

Event Filtering and Routing

Filtering is the mechanism that gives EventBridge its intelligence. Rather than forcing every downstream service to receive and discard irrelevant events, EventBridge inspects the content of the event envelope before delivery. You define 'Rule Patterns' that match specific fields within the JSON structure, such as the source, the resource type, or specific data attributes within the detail payload. This routing efficiency is critical because it minimizes the compute overhead on target services and reduces overall architectural complexity. When an event pattern matches, the service routes the payload to one or more predefined targets, such as a function or a queue. This selective routing approach allows you to implement complex event-driven logic where different services respond only to the specific state changes relevant to their business domains. By shifting the filtering responsibility to the bus, you reduce the boilerplate code that would otherwise be required inside every microservice.

# A pattern matching rule to capture only orders over $50
aws events put-rule --name "HighValueOrderRule" --event-pattern '{
  "source": ["order.service"],
  "detail": {
    "total": [{ "numeric": [">", 50] }]
  }
}'

Integrating AWS Service Events

Every AWS service inherently emits events to the default event bus, documenting changes in system state such as instance launches, database snapshots, or file uploads. By leveraging these native events, you can transform static infrastructure into an automated, self-healing system. For example, you can trigger a security compliance function the moment an IAM policy is modified or initiate an automated database backup upon an S3 bucket event. This capability removes the need for polling or custom monitoring scripts, which are traditionally resource-intensive and prone to failure. Because these events are standardized, you can easily create rules that aggregate data across disparate services to provide real-time visibility into your architectural state. Understanding that the cloud itself is a stream of events is the key to mastering AWS automation; you stop managing resources and start managing the lifecycle of events as they transit through the bus.

# A rule that triggers on any EC2 state change to 'terminated'
aws events put-rule --name "MonitorTerminatedInstances" --event-pattern '{
  "source": ["aws.ec2"],
  "detail-type": ["EC2 Instance State-change Notification"],
  "detail": { "state": ["terminated"] }
}'

Schema Registry and Discovery

Managing the structure of event data is a significant challenge in large distributed systems. The Schema Registry acts as a central repository for the structure of your events, allowing teams to share and document event contracts. When an event is ingested, the service can automatically generate a schema definition based on the JSON payload. This is invaluable because it provides a versioned, searchable definition that downstream developers can use to generate local code models. By enforcing a contract through schemas, you reduce the risk of breaking downstream consumers when you update an event source. The registry also allows you to perform schema validation, ensuring that only well-formed data enters your pipeline. Utilizing the registry turns implicit knowledge about data formats into explicit, accessible documentation, which is vital for maintaining long-term developer velocity and reducing integration bugs across large engineering organizations.

# Example of creating a schema version manually for an event type
aws schemas create-schema --registry-name "OrderRegistry" --schema-name "OrderCreated" --type "JSONSchemaDraft4" --content '{
  "type": "object",
  "properties": { "orderId": { "type": "string" } }
}'

Handling Latency and Delivery Retries

In distributed systems, failures are inevitable; services will be temporarily unreachable or slow. EventBridge handles this gracefully through built-in, configurable retry policies that allow for asynchronous delivery attempts over a 24-hour window. If a target fails to respond, the bus automatically retries the delivery using an exponential backoff strategy, ensuring that transient connectivity issues do not result in lost business critical data. For cases where processing fails repeatedly, you can configure a Dead Letter Queue (DLQ) to capture the failed events for manual inspection and troubleshooting. This 'eventual consistency' approach is the standard for distributed messaging, favoring reliability over the immediate synchronous acknowledgment required in monolithic architectures. By designing your services to be idempotent—meaning they can handle the same event multiple times without side effects—you can take full advantage of the reliable, retriable delivery mechanisms provided by the event bus.

# Attaching a DLQ to an event target to capture failed attempts
aws events put-targets --rule "OrderRule" --targets '[{
  "Id": "TargetFunction",
  "Arn": "arn:aws:lambda:us-east-1:123:function:my-func",
  "DeadLetterConfig": { "Arn": "arn:aws:sqs:us-east-1:123:failed-events-queue" }
}]'

Key points

  • EventBridge acts as a serverless event bus that decouples producers and consumers.
  • Rules enable intelligent routing of events based on their content rather than simple endpoints.
  • AWS service events are native, allowing for deep automation of infrastructure state changes.
  • The Schema Registry provides a contract for event structures to ensure team interoperability.
  • Asynchronous delivery includes built-in retry mechanisms and exponential backoff to handle transient failures.
  • Dead Letter Queues are essential for isolating and investigating events that cannot be processed by targets.
  • Idempotency in target services is required to handle potential duplicate events during retries.
  • Event-driven architecture shifts the system model from manual polling to reactive automated processing.

Common mistakes

  • Mistake: Configuring EventBridge to trigger a Lambda function without setting the appropriate resource-based policy. Why it's wrong: EventBridge needs explicit permission to invoke the function. Fix: Use the add-permission command or console settings to grant 'lambda:InvokeFunction' to the events.amazonaws.com service principal.
  • Mistake: Assuming that EventBridge Rule delivery is strictly guaranteed in real-time without failure handling. Why it's wrong: While highly reliable, distributed systems face transient issues. Fix: Configure a Dead Letter Queue (DLQ) on the rule to capture events that failed to be delivered after retries.
  • Mistake: Using EventBridge for high-frequency data streaming instead of data ingestion. Why it's wrong: EventBridge is designed for event-driven orchestration, not high-throughput data pipelines. Fix: Use Kinesis Data Streams if you need to process large volumes of streaming records at high frequency.
  • Mistake: Over-relying on the default event bus for custom application events. Why it's wrong: The default bus is shared with AWS service events, making it harder to manage security and access controls. Fix: Create custom event buses for specific applications or microservices to improve isolation and security.
  • Mistake: Attempting to use EventBridge to order events precisely. Why it's wrong: EventBridge is a distributed system; it guarantees at-least-once delivery, not strict global ordering. Fix: Design your consumer logic to be idempotent so that out-of-order or duplicate events do not corrupt the state.

Interview questions

What is Amazon EventBridge and why would you use it in an AWS architecture?

Amazon EventBridge is a serverless event bus service that makes it easy to connect your applications using data from your own applications, integrated software as a service applications, and AWS services. You would use it to build event-driven architectures because it decouples your services, allowing them to scale independently. By using an event bus, producers do not need to know who the consumers are, which significantly reduces architectural complexity while improving maintainability.

Explain the role of an Event Rule and an Event Target in EventBridge.

An Event Rule matches incoming events based on a specified pattern and routes them to one or more targets. The rule acts as the intelligence layer, evaluating the JSON content of the event. A target is the resource that receives the event once a match occurs, such as a Lambda function, SQS queue, or SNS topic. This setup is crucial because it allows you to filter specific events and trigger automated actions or workflows programmatically without writing custom polling code.

How does EventBridge handle schema discovery and why is this useful for development?

Schema discovery is a feature that automatically identifies the structure of events sent to an EventBridge bus and generates a schema in the Schema Registry. This is highly beneficial because it allows developers to generate code bindings for their applications, ensuring that producers and consumers are synchronized on the data format. By eliminating the manual effort of documenting event shapes, it reduces integration bugs and speeds up the development lifecycle for complex, event-driven systems.

Compare using Amazon EventBridge versus Amazon SNS for inter-service communication.

While both services support pub/sub models, EventBridge is primarily designed for event-driven application integration, providing rich content-based routing using event patterns. In contrast, Amazon SNS is optimized for high-throughput messaging and fan-out to endpoints like email or mobile notifications. You choose EventBridge when you need complex logic based on the event payload, whereas you choose SNS when you need simple, broad broadcast functionality to many subscribers with minimal filtering requirements.

How can you implement dead-letter queues (DLQ) in EventBridge and why is it considered a best practice?

To implement a DLQ in EventBridge, you configure an Amazon SQS queue as a target for your rule and set it as the dead-letter queue in the rule's target configuration. This is a vital best practice for fault tolerance; if EventBridge fails to deliver an event to a target after multiple retries, it moves the event to the SQS queue. This allows you to inspect failed events later, perform debugging, and ensure that no critical data is lost due to transient network or service issues.

Describe how to use EventBridge Pipes to integrate with other AWS services efficiently.

EventBridge Pipes provides a point-to-point integration between event producers and consumers, reducing the need for boilerplate integration code. You can define a source, such as an SQS queue or Kinesis stream, apply an optional filtering or enrichment step using Lambda, and then route it to a target like an API Gateway or step function. This approach is superior to manual orchestration because it handles polling, batching, and error handling automatically, significantly lowering the total cost of ownership.

All AWS interview questions →

Check yourself

1. An architect wants to route events from different AWS accounts to a central security account. Which mechanism is most appropriate?

  • A.Create an IAM user in the security account and share credentials with other accounts
  • B.Configure cross-account event buses with specific resource-based policies
  • C.Enable CloudTrail across all accounts and aggregate logs in S3
  • D.Use a single central Lambda function that polls all other account event sources
Show answer

B. Configure cross-account event buses with specific resource-based policies
EventBridge natively supports cross-account event routing via custom buses and resource policies. Using IAM credentials is a security risk. S3 log aggregation is for audit, not event-driven routing. Polling is inefficient and violates the push-based nature of EventBridge.

2. You have a rule matching S3 object creation events. Why might some events fail to reach your target?

  • A.The event size exceeds the 128KB limit for custom events
  • B.The event bridge bus is limited to 10 events per second
  • C.The rule lacks permissions to invoke the target, or the target has reached its concurrency limit
  • D.S3 events are not supported in EventBridge without using SNS as an intermediary
Show answer

C. The rule lacks permissions to invoke the target, or the target has reached its concurrency limit
EventBridge needs resource-based permissions to trigger targets like Lambda. If the target reaches its concurrency limit, the invocation will fail. The other options are incorrect because S3 events are natively integrated, and the throughput limits are much higher.

3. What is the primary benefit of using Input Transformers in an EventBridge rule?

  • A.To filter out unwanted events before they reach the bus
  • B.To convert the raw event into a specific format required by the downstream target
  • C.To encrypt the event payload for compliance
  • D.To increase the speed of event delivery
Show answer

B. To convert the raw event into a specific format required by the downstream target
Input Transformers allow you to map or transform the event JSON structure into the specific payload format your target expects. They do not perform filtering, encryption, or speed optimization.

4. When a target is down, how does EventBridge handle event delivery?

  • A.It discards the event immediately to prevent latency
  • B.It retries for 24 hours with an exponential backoff strategy
  • C.It waits indefinitely until the target recovers
  • D.It automatically reroutes the event to an SQS queue without configuration
Show answer

B. It retries for 24 hours with an exponential backoff strategy
EventBridge provides built-in retry logic that persists for up to 24 hours using exponential backoff. It does not discard immediately, wait indefinitely, or reroute to SQS without explicit configuration of a DLQ.

5. If you need to archive events for long-term analysis and replay them later, what should you configure?

  • A.EventBridge Archives
  • B.EventBridge Global Endpoints
  • C.EventBridge Schemas
  • D.EventBridge Pipes
Show answer

A. EventBridge Archives
EventBridge Archives allow you to store events and replay them at a later time. Schemas are for IDE integration, Pipes are for point-to-point integration, and Global Endpoints are for high availability across regions.

Take the full AWS quiz →

← PreviousSNS — Simple Notification ServiceNext →Glue — ETL Service

AWS

24 lessons, free to read.

All lessons →

Track your progress

Sign in to mark lessons done, score quizzes and keep notes.

Open in the app