-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws-lambda-event-sources': filters option not filtering items #26408
Comments
Can you share your cdk synth output? |
@pahud Sure, here is the relevant section (if you need it all just let me know, I'l get back ASAP)
|
Hey @ETisREAL Thanks for the template, However I can't reproduce this issue in the latest version of CDK. Template code import * as cdk from 'aws-cdk-lib';
import { Construct } from 'constructs';
import * as lambda from 'aws-cdk-lib/aws-lambda'
import * as lambda_event_sources from 'aws-cdk-lib/aws-lambda-event-sources'
import { DynamoDbDataSource } from 'aws-cdk-lib/aws-appsync';
import { Table } from 'aws-cdk-lib/aws-dynamodb';
import * as dynamodb from 'aws-cdk-lib/aws-dynamodb';
// import * as sqs from 'aws-cdk-lib/aws-sqs';
export class BuildStack extends cdk.Stack {
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
const DB = new dynamodb.TableV2(this, "newbkt",{
partitionKey: {
name: 'id',
type: dynamodb.AttributeType.STRING,
},
dynamoStream: dynamodb.StreamViewType.OLD_IMAGE,
}
);
const leaderboardsStreamHandler = new lambda.Function(this, 'leaderboardsStreamHandler', {
functionName: 'leaderboardsStreamHandler',
code: lambda.Code.fromInline("abc"),
handler: 'leaderboardsStreamHandler.handler',
runtime: lambda.Runtime.NODEJS_18_X,
events: [
new lambda_event_sources.DynamoEventSource(DB, {
startingPosition: lambda.StartingPosition.TRIM_HORIZON,
retryAttempts: 2,
batchSize: 1,
filters: [
lambda.FilterCriteria.filter({
dynamodb: { Keys: { PK: {S: lambda.FilterRule.beginsWith('PARTICIPANT#')}, SK: {S: lambda.FilterRule.beginsWith('#TOURNAMENT#')} } }
})
]
})
],
description: 'Lambda function responsible for creating and updating leaderboards'
})
}
} The created Event Source Mapping
I can see the Filters Pattern is correctly generated. |
Hello @roger-zhangg eventually I got it to work. Can't really tell if I changed something somewhere else or if there was a bug in the CDK. Either way, thank you very much for your time :) Much appreciated |
|
Describe the bug
I am trying to filter the items my dynamodb table streams out in order to avoid unnecessary invocations and cut on costs.
This is my code;
Expected Behavior
The event is mapped correctly, so I would expect the items to get filtered on this basis (PK = 'value' and begins_with(SK, 'value')
Current Behavior
Currently no filtering is getting applied. I always receive all the events
Reproduction Steps
Try with the provded code above
Possible Solution
Probaily some miscofiguration or missing functionality in the filtering
Additional Information/Context
No response
CDK CLI Version
2.87
Framework Version
No response
Node.js Version
v18.04
OS
Linux - Ubuntu
Language
Typescript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: