-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(events): Unable to use content based filtering patterns in detailType #30220
Copy link
Copy link
Open
Labels
@aws-cdk/aws-eventsRelated to CloudWatch EventsRelated to CloudWatch EventsbugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp2
Description
Describe the bug
When using the L2 construct for EventBridge Rules a type failure occurs when attempting to create an event bridge rule that uses content based filtering patterns. Requiring the use of a trapdoor in order to achieve the desired results.
Expected Behavior
Content based filtering patterns are supported in an events detailType
Current Behavior
Type '{ prefix: string; }' is not assignable to type 'string'
Reproduction Steps
#!/usr/bin/env node
import 'source-map-support/register';
import * as cdk from 'aws-cdk-lib';
import { Rule, CfnRule } from 'aws-cdk-lib/aws-events';
const app = new cdk.App();
const stack = new cdk.Stack(app, 'RuleTestStack');
const rule = new Rule(stack, 'Rule', {
eventPattern: {
detailType: [{"prefix": "shared_"}]
}
});
Possible Solution
See #30222
Using a trapdoor does provide a work around
(rule.node.defaultChild as CfnRule).addOverride('Properties.EventPattern.detail-type', [{"prefix": "shared_"}])
Additional Information/Context
No response
CDK CLI Version
2.141.0
Framework Version
No response
Node.js Version
18.18.0
OS
OSX
Language
TypeScript
Language Version
Typescript 5.4.0
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-eventsRelated to CloudWatch EventsRelated to CloudWatch EventsbugThis issue is a bug.This issue is a bug.effort/mediumMedium work item – several days of effortMedium work item – several days of effortp2