1 Answer
- Newest
- Most votes
- Most comments
-1
To filter out TTL deletions, you can't directly set up a filter on the event source mapping in Lambda. Instead, you can add a conditional check within your Lambda function to filter out TTL deletions based on the userIdentity field in the event record.
Here's an example of how you can modify your Lambda function to filter out TTL deletions:
import json
def lambda_handler(event, context):
for record in event['Records']:
if ('userIdentity' not in record['dynamodb']['NewImage']) or (record['dynamodb']['NewImage']['userIdentity']['principalId'] != 'dynamodb.amazonaws.com'):
# Process the non-TTL deletion event
print("Non-TTL event:", json.dumps(record, indent=2))
This code snippet checks each record in the event to see if the userIdentity field is present and if its principalId is equal to 'dynamodb.amazonaws.com'. If the condition is false, it processes the non-TTL event. By doing so, your Lambda function only processes events that are not TTL deletions.
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 7 months ago
I've never seen a DDB streams event with eventName DELETE. According to AWS documentation, it is not a valid value: https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_streams_Record.html