I have a DynamoDB table where TTL is enabled. I want to trigger a Lambda function whenever an record is deleted due to TTL.
Here's what I have tried:
1. Adding DynamoDB as an AWS trigger is not helping me (Lambda is triggering), as it does not provide sufficient information to determine if the entry was deleted by TTL or some other means.
2. I attempted to create a custom log group for DynamoDB, but I couldn't succeed. If it is possible, please assist me.
3. Creating an EventBridge rule whenever CloudWatch alarm state changes is triggering lambda twice and on top of it i don't know how to pass information of deleted record with it.
Please help me out.
Thank you in advance.
Adding DynamoDB as an AWS trigger is actually sufficient. It does indeed provide sufficient information to determine if the entry was deleted by TTL or some other means. See https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-streams.html
The streams record contains a user identity field Records[].userIdentity.
Items that are deleted by the Time to Live process after expiration have the following fields:
Records[].userIdentity.type: "Service"
Records[].userIdentity.principalId: "dynamodb.amazonaws.com"