I have configured a lambda function to take DynamoDb Stream as trigger. It seems to pick up all events on the DynamoDb
Is there any options to invoke Lambda only on certain type of event ( DynamoDB item delete ) so that Lambda function will not be fired on every action?
The goal is to save the cost of invoking lambda function for events that I dont need.
There is no such options as far as I know. DynamoDB updates its stream data whenever any item is created, modified and deleted. Any change in the stream invokes the lambda function. You can check for "eventName" value as "REMOVE" in the event from dynamodb and only process that event.
There is now a way to do that,
https://aws.amazon.com/blogs/compute/filtering-event-sources-for-aws-lambda-functions/
It's a new feature of lambda, it uses the same syntax as AWS Eventbdridge.
aws lambda create-event-source-mapping \
--function-name fleet-tire-pressure-evaluator \
--batch-size 100 \
--starting-position LATEST \
--event-source-arn YOUR_DB_STREAM_ARN \
--filter-criteria '{"Filters": [{"eventName": ["EventA"]}]}'
You can refer to this documentation to know the exact syntax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With