- Newest
- Most votes
- Most comments
Hi Kumar,
I believed we resolved this issue internally. DynamoDB Stream should have view type set to NEW_AND_OLD_IMAGE.
It seems that you're experiencing an issue where your Lambda function is not being triggered when changes are made to the DynamoDB table A2D_Ruleset, specifically when the ruleset_code column is updated, added, or deleted. This is a common issue that can occur due to several reasons. Let's explore some potential causes and solutions:
-
DynamoDB Streams Configuration: Ensure that DynamoDB Streams is properly enabled for your A2D_Ruleset table. Without Streams enabled, Lambda won't receive any change events.
-
Lambda Trigger Configuration: Verify that the Lambda trigger is correctly set up to listen to the DynamoDB stream. Check the function's trigger configuration in the Lambda console to ensure it's associated with the correct DynamoDB table and stream.
-
IAM Permissions: Make sure your Lambda function has the necessary permissions to read from the DynamoDB stream. The function's execution role should have the AWSLambdaDynamoDBExecutionRole policy or equivalent permissions.
-
Stream Record Filtering: If you're only interested in changes to the ruleset_code column, ensure that your Lambda function is correctly filtering the incoming stream records to process only the relevant changes.
-
Lambda Function Logic: Review your Lambda function code to ensure it's correctly processing the DynamoDB stream events. The function should be able to handle different types of events (INSERT, MODIFY, REMOVE) and extract the relevant information from the event records.
-
Monitoring and Logging: Enable detailed logging in your Lambda function and check CloudWatch Logs for any error messages or unexpected behavior. This can help identify if the function is being invoked but failing silently.
-
Stream Processing Delay: Be aware that there can be a slight delay between when a change occurs in DynamoDB and when the Lambda function processes it. This delay is usually minimal but can vary.
-
Testing Methodology: When testing, make sure you're making changes directly to the DynamoDB table rather than through the Lambda function's test event. The test event you mentioned works because it's directly invoking the Lambda function, not simulating a DynamoDB stream event.
If you've verified all these points and the issue persists, you may want to double-check the DynamoDB stream's status and consider re-creating the trigger. Sometimes, re-establishing the connection between the stream and the Lambda function can resolve such issues.
Remember to monitor your function's invocations and errors using CloudWatch metrics to get a better understanding of its behavior in production.
Sources
DynamoDB Streams and AWS Lambda triggers - Amazon DynamoDB
Process DynamoDB records with Lambda - AWS Lambda
Invoke a Lambda function from a DynamoDB trigger - AWS Lambda
answered 2 years ago
Relevant content
asked 3 years ago
asked 3 years ago
- AWS OFFICIALUpdated 5 months ago
