Amazon EventBridge: The missing piece to your app
Tags: aws, serverless, eventbridge, eventdriven
Published: 2023-03-05 14:25:10

[Amazon EventBridge](https://aws.amazon.com/eventbridge/) is a Serverless AWS Service that enables building event-driven applications with seamless integrations with multiple AWS Services and AWS Partner SaaS applications.

Launched in 2019, it was focused on building pathways for SaaS Product events to be consumed and routing the events to the AWS Lambda function. It initially supported buses and CloudWatch Events which was previously part of AWS CloudWatch. Since then, a lot of powerful features have been added to EventBridge to build an event-driven Serverless app.

## EventBridge Buses

![EventBridge buses in an architecture](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vlnmfjax2fz60ncu2znl.png)

*Event Buses* are the communication channel that receives events from different *event sources* which could be AWS Services such as Amazon S3 which is posting in events whenever there is any action happening in an S3 bucket, programmatically using *EventBridge APIs* to `send` events to a *default* or *custom bus* or events from a partner SaaS product posting events to a defined *SaaS event bus*. Once the events are available on the bus, *event rules* are used to route the event to the right designation these rules have powerful filtering capabilities which can be applied to event payloads.

Some scenarios, where you would be using it in your application -

* An S3 event that is `putObject` event would be routed to AWS Lambda functions for further computation or AWS Step Functions to kick-start a state machine execution.
    
* An S3 event that is `deleteObject` would result in invoking an API destination that would use the *Input Transformer* to restructure the event as per API's specifications.
    

Note: these rules are specific to event buses, and there can be multiple rules in a bus.

## EventBridge Pipes

![Sample EventBridge Pipe](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zyickxifo9xy2fdxe7jf.png)

*EventBridge Pipes* enable direct point-to-point integrations from defined event sources like Amazon DynamoDB streams, Amazon Kinesis, Amazon SQS, and more which can be filtered with advanced EventBridge filtering on the event payloads.

```json
{
  "eventName": [{
    "prefix": "INSERT"
  }]
}
```

The filtered events could be enriched to uplift the data before it is delivered to the target AWS Service. *Input Transformer* is available for the *enrichment* and *target* states which can transform to the expected payload structure by the AWS Service and also define the output path.

EventBridge Pipes, opening up the direct service integration with advanced filtering and enrichment

* EventBridge Pipe uses events from DynamoDB streams on any action on a DynamoDB table and would use filtering to process only `eventName: INSERT` for newly created items on DynamoDB and invoke a state machine execution.
    
* New messages from Amazon MQ could be used to start a state machine execution.
    

## EventBridge Scheduler

![A sample EventBridge Scheduler with cron job](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6tyg11f9mte2zxug4kop.png)

*EventBridge Scheduler* is a way to schedule your tasks that happen from time to time and need recurring events with corn expressions, time windows, and one time with a specific date and time. These events from the scheduler could be targeted to a specific AWS Service where the event payload set in the scheduler will be delivered.

* Tasks that have to be performed every day at a specific time (like 1 am).
    
* Workloads that generate billing every month where the scheduler can invoke a Lambda function to generate bills.
    

## In a nutshell

Amazon EventBridge can be a crucial component of your Serverless applications which could be *solution-ed* to deliver the right events effectively to the destinations. For Event-driven architectures that consume a multitude of events, EventBridge can easily scale, and events can be filtered with advanced filtering capabilities. EventBridge eliminates the glue-coded Lambda functions which might contain additional logic to validate the events against certain patterns which are necessary to the application for further processing. EventBridge Pipes enhances your Serverless workload with direct service integration that positively affects the application's performance and scalability.

In any application, the design might contain multiple features by Amazon EventBridge where specific tasks could be scheduled with an *EventBridge Scheduler*, all events could be sent to an *Event Bus* which would use *Event Rules* to route the events to the designated targets or have point-to-point integrations with AWS services as producer and consumer for smooth orchestration.