11
votes

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'?

2

2 Answers

18
votes

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)

4
votes

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') == 'DELETE':
        pass
    elif record.get('eventName') ==  'MODIFY':
        pass