'Configure DynamoDB stream trigger with insert only

I currently have an AWS DynamoDB stream triggers a Lambda function.

The Lambda function is triggered by both insert and update events in the DynamoDB. Is there a way to change the configuration so that the Lambda function would only be triggered by 'insert'?



Solution 1:[1]

To my knowledge this is not possible. AWS Lambda polls the stream and invokes your Lambda function when it detects any type of stream record update. Your Lambda will have to ignore the records that you are not interested in. You can use the eventName property of the stream record (can have values INSERT | MODIFY | REMOVE)

Solution 2:[2]

You can use your lambda function to ignore rest other than insert.

 for record in event.get('Records'):
    if record.get('eventName') in ('INSERT'):
       """ code for execution. """

    elif record.get('eventName') == 'REMOVE':
        pass
    elif record.get('eventName') ==  'MODIFY':
        pass

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Fennema
Solution 2 Antash