Reputation: 580
I'd like to deploy an AWS Event Rule in Eventbridge which is triggered by all events, with no filtering whatsoever.
I've tried the following patterns with no luck.
{
source: ["*"]
}
According to the documentation you cannot leave the pattern empty. Also, any fields not included in the pattern are wildcarded meaning they can be any value.
I've read articles saying Eventbridge can replace services such as SNS and SQS but without these finer controls I don't see that happening.
Thanks
Upvotes: 21
Views: 17122
Reputation: 51
For anyone that is looking for the CDK-Python version, it can be achieved with:
event_pattern=aws_events.EventPattern(
source=aws_events.Match.prefix(""), # Do not filter anything
)
This follows the prefix
approach explained in this response (https://stackoverflow.com/a/62407802/13957271).
Upvotes: 3
Reputation: 239000
Based on the comments.
The solution was to use empty prefix to match all events:
{
"source": [{
"prefix": ""
}]
}
Upvotes: 35
Reputation: 378
For CDK in TypeScript you can provide a match pattern using as any[]
:
import * as cdk from 'aws-cdk-lib';
const catchAllRule = new cdk.aws_events.Rule(stack, 'CatchAllRule', {
targets: [...],
eventBus: ...,
eventPattern: {
source: [ { prefix: ''} ] as any[]
}
});
Generates this CloudFormation:
EventId:
Type: AWS::Events::Rule
Properties:
EventBusName:
Ref: ...
EventPattern:
source:
- prefix: ""
State: ENABLED
This works in TypeScript. In other languages you may have to use escape hatch and override the property.
References:
Relevant issues:
Upvotes: 7
Reputation: 1
Using serverless framework you can use the following event pattern to receive ALL events from the bus eventBusName
for your account with ID accountID
:
- eventBridge:
eventBus: arn:aws:events:${aws:region}:${aws:accountId}:event-bus/eventBusName
pattern:
account: ["accountID"]
Upvotes: 0
Reputation: 3397
You can try to use exists
filter: https://docs.aws.amazon.com/eventbridge/latest/userguide/content-filtering-with-event-patterns.html#filtering-exists-matching
One caveat of using this is that it's not working properly when defined in CloudFormation, but at least it works in SDK and in console.
Upvotes: 3