Websockets with EventBridge
CDK Construct to setup a WebSocket for EventBridge in seconds.
Features
-
WebSocket
- Step into your events in real time using WebSockets.
-
Custom Event Pattern
- You define what to listen for.
-
Setup in seconds
- Easy to use construct, get up and running in seconds.
-
OpenSource
- Feel free to fork and contribute.
Why cdk-eventbridge-socket
This is an AWS CDK Construct that will listen for any EventBridge Bus and Rule and forward that event through a websocket.
Get setup in seconds and as easy as 7 lines of code.
Why
You may want to use tools like Postman Websockets or websocat to see and debug what events are being fired through your event bus.
How
This uses AWS ApiGateway, DynamoDB (to store connections) and Lambda.
Installation
1npm install cdk-eventbridge-socket
Example of use
You can listen to any EventBridge source/pattern you like, just replace the eventPattern with what you want to listen too.
1import * as cdk from '@aws-cdk/core';
2
3import { EventBridgeWebSocket } from 'cdk-eventbridge-socket';
4
5export class EventbridgeWebhooksStack extends cdk.Stack {
6 constructor(scope: cdk.App, id: string, props?: cdk.StackProps) {
7 super(scope, id, props);
8
9 new EventBridgeWebSocket(this, 'sockets', {
10 bus: 'your-event-bus-name',
11
12 // This example shows how to listen for all events
13 eventPattern: {
14 account: ['your_account_id'],
15 },
16 stage: 'dev',
17 });
18 }
19}
cdk-eventbridge-socket
CDK construct
- Open Source
- 100%
- Setup in seconds
- 10s
- Customise what to listen for
- Pattern