This is a CDK construct library that allows you to easily create an EventBridge rule that sends events to an SQS queue.
Why not use AWS Solutions constructs aws-eventbridge-sqs
?
Because it doesn't support message group id.
So, that's why.
npm install cdk-eventbridge-to-sqs
import { EventbridgeToSqs } from "cdk-eventbridge-to-sqs";
const { queue, eventBus } = new EventbridgeToSqs(this, "EventbridgeToSqs");
const { queue, eventBus } = new EventbridgeToSqs(this, "EventbridgeToSqs", {
eventBusProps: {
eventBusName: "MyEventBus",
},
queueProps: {
queueName: "MyQueue",
},
});
const { queue, eventBus } = new EventbridgeToSqs(this, "EventbridgeToSqs", {
eventBusProps: {
eventBusName: "MyEventBus",
},
queueProps: {
fifo: true,
},
deadLetterQueueProps: {
fifo: true,
},
deployDeadLetterQueue: true,
messageGroupId: "MyMessageGroupId",
});
declare const queue: Queue;
declare const eventBus: EventBus;
new EventbridgeToSqs(this, "EventbridgeToSqs", {
existingEventBusInterface: eventBus,
existingQueueObj: queue,
});
declare const queue: Queue;
declare const eventBus: EventBus;
new EventbridgeToSqs(this, "EventbridgeToSqs", {
existingEventBusInterface: eventBus,
existingQueueObj: queue,
eventRuleFilterPattern: {
detailType: ["MyDetailType"],
source: ["MySource"],
},
});
import { EventbridgeToSqs } from 'cdk-eventbridge-to-sqs'
new EventbridgeToSqs(scope: Construct, id: string, props?: EventbridgeToSqsProps)
Name | Type | Description |
---|---|---|
scope |
constructs.Construct |
No description. |
id |
string |
No description. |
props |
EventbridgeToSqsProps |
No description. |
- Type: constructs.Construct
- Type: string
- Type: EventbridgeToSqsProps
Name | Description |
---|---|
toString |
Returns a string representation of this construct. |
public toString(): string
Returns a string representation of this construct.
Name | Description |
---|---|
isConstruct |
Checks if x is a construct. |
import { EventbridgeToSqs } from 'cdk-eventbridge-to-sqs'
EventbridgeToSqs.isConstruct(x: any)
Checks if x
is a construct.
Use this method instead of instanceof
to properly detect Construct
instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs
library on
disk are seen as independent, completely different libraries. As a
consequence, the class Construct
in each copy of the constructs
library
is seen as a different class, and an instance of one class will not test as
instanceof
the other class. npm install
will not create installations
like this, but users may manually symlink construct libraries together or
use a monorepo tool: in those cases, multiple copies of the constructs
library can be accidentally installed, and instanceof
will behave
unpredictably. It is safest to avoid using instanceof
, and using
this type-testing method instead.
- Type: any
Any object.
Name | Type | Description |
---|---|---|
node |
constructs.Node |
The tree node. |
eventBus |
aws-cdk-lib.aws_events.IEventBus |
No description. |
queue |
aws-cdk-lib.aws_sqs.Queue |
No description. |
rule |
aws-cdk-lib.aws_events.Rule |
No description. |
deadLetterQueue |
aws-cdk-lib.aws_sqs.DeadLetterQueue |
No description. |
public readonly node: Node;
- Type: constructs.Node
The tree node.
public readonly eventBus: IEventBus;
- Type: aws-cdk-lib.aws_events.IEventBus
public readonly queue: Queue;
- Type: aws-cdk-lib.aws_sqs.Queue
public readonly rule: Rule;
- Type: aws-cdk-lib.aws_events.Rule
public readonly deadLetterQueue: DeadLetterQueue;
- Type: aws-cdk-lib.aws_sqs.DeadLetterQueue
The properties for the EventbridgeToSqs class.
import { EventbridgeToSqsProps } from 'cdk-eventbridge-to-sqs'
const eventbridgeToSqsProps: EventbridgeToSqsProps = { ... }
Name | Type | Description |
---|---|---|
deadLetterQueueProps |
aws-cdk-lib.aws_sqs.QueueProps |
Properties for the dead letter queue, if deployDeadLetterQueue is true. |
deployDeadLetterQueue |
boolean |
Whether to deploy a dead letter queue for the main queue. |
enableQueuePurging |
boolean |
Whether to enable queue purging. |
eventBusProps |
aws-cdk-lib.aws_events.EventBusProps |
Properties for the new event bus that will be created. |
eventRuleFilterPattern |
aws-cdk-lib.aws_events.EventPattern |
Event pattern to use for the event rule Defaults to an event pattern that matches all events in the same region as the event bus. |
eventRuleProps |
aws-cdk-lib.aws_events.RuleProps |
Properties for the new event rule that will be created. |
existingEventBusInterface |
aws-cdk-lib.aws_events.EventBus |
An existing event bus to bind the rule to. |
existingQueueObj |
aws-cdk-lib.aws_sqs.Queue |
Existing queue object to bind the event source to. |
maxReceiveCount |
number |
Max receive count for the dead letter queue. |
messageGroupId |
string |
The message group id to use for fifo queues. |
queueProps |
aws-cdk-lib.aws_sqs.QueueProps |
Properties for the new queue that will be created, if no existing queue is provided. |
public readonly deadLetterQueueProps: QueueProps;
- Type: aws-cdk-lib.aws_sqs.QueueProps
- Default: None
Properties for the dead letter queue, if deployDeadLetterQueue is true.
public readonly deployDeadLetterQueue: boolean;
- Type: boolean
- Default: false
Whether to deploy a dead letter queue for the main queue.
public readonly enableQueuePurging: boolean;
- Type: boolean
- Default: false
Whether to enable queue purging.
If true, the queue will be purged before deployment
public readonly eventBusProps: EventBusProps;
- Type: aws-cdk-lib.aws_events.EventBusProps
- Default: None
Properties for the new event bus that will be created.
public readonly eventRuleFilterPattern: EventPattern;
- Type: aws-cdk-lib.aws_events.EventPattern
- Default: None
Event pattern to use for the event rule Defaults to an event pattern that matches all events in the same region as the event bus.
public readonly eventRuleProps: RuleProps;
- Type: aws-cdk-lib.aws_events.RuleProps
- Default: None
Properties for the new event rule that will be created.
public readonly existingEventBusInterface: EventBus;
- Type: aws-cdk-lib.aws_events.EventBus
- Default: A new event bus will be created
An existing event bus to bind the rule to.
public readonly existingQueueObj: Queue;
- Type: aws-cdk-lib.aws_sqs.Queue
- Default: None
Existing queue object to bind the event source to.
If not provided, a new queue will be created. If an existing queue is provided, the queue will not be modified unless enableQueuePurging is set to true or deployDeadLetterQueue is set to true
public readonly maxReceiveCount: number;
- Type: number
- Default: 3
Max receive count for the dead letter queue.
public readonly messageGroupId: string;
- Type: string
The message group id to use for fifo queues.
public readonly queueProps: QueueProps;
- Type: aws-cdk-lib.aws_sqs.QueueProps
- Default: None
Properties for the new queue that will be created, if no existing queue is provided.