(events): Unable to use content based filtering patterns in detailType
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
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](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns-content-based-filtering.html). 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 https://github.com/aws/aws-cdk/pull/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_
Contributor guide
Research direction
Start in the aws-events Rule eventPattern types, focusing on detailType and the CfnRule override shown in the report. Confirm the type accepts content-based filtering objects such as {"prefix":"shared_"}, then verify that the example can synthesize without using a trapdoor.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100