(lambda): Improve `FilterCriteria` documentation
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 74
Description
### Describe the bug
The documentation [here](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_lambda-readme.html#event-sources) leads to a malformed template for EventSource filters
### Expected Behavior
I expect the code in the docs to work, and if it doesn't, I expect to have a good enough understanding to work around the limitation in the example.
### Current Behavior
The code seen here:
```
fn.addEventSource(new eventsources.DynamoEventSource(table, {
startingPosition: lambda.StartingPosition.LATEST,
filters: [{ eventName: lambda.FilterRule.isEqual('INSERT') }],
}));
```
will provide this output in CloudFormation
```
FilterCriteria:
Filters:
- {}
```
And the example doesn't leave any good hints as to what the right thing to do is
### Reproduction Steps
Synthesize the docs
### Possible Solution
The correct code is this:
```
fn.addEventSource(new DynamoEventSource(table, {
startingPosition: lambda.StartingPosition.LATEST,
filters: [FilterCriteria.filter({ eventName: lambda.FilterRule.isEqual('INSERT') })],
}));
```
### Additional Information/Context
_No response_
### CDK CLI Version
latest
### Framework Version
_No response_
### Node.js Version
16
### OS
mac
### Language
Typescript
### Language Version
_No response_
### Other information
We need to explain how to implement different kinds of filters, rather than just providing an example
Contributor guide
Research direction
Start at the AWS CDK API v2 event-sources documentation linked in the issue and compare the FilterCriteria example with the synthesized CloudFormation output. Update the example and explain how to implement different filter kinds; it is done when the documented examples synthesize valid FilterCriteria rather than an empty filter object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cloud, documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100