skip to Main Content

We’re planning to add a few updates in Lambda Function which has been set as the trigger for DynamoDB New item Events

DynamoDB –> DynamoDB Streams –> AWS Lambda

So while performing an update, we need to make sure no events should be received by lambda.

Are there any easy-to-implement methods to do this??

2

Answers


  1. First of all why are you using EventBridge?

    The path should be DynamoDB -> DynamoDB Streams -> Lambda.

    To ensure the Lambda only receives new items you can use a Lambda Event Filter

    {
      "filters": [
        {
          "pattern": "{"eventName" : ["INSERT"] }"
        }
      ]
    }
    
    Login or Signup to reply.
  2. Option 1: Streams -> Lambda (with enable/disable)

    DynamoDB Streams can send events directly to Lambda using the Event Source Mapping integration. An Event Source Mapping is an AWS-managed poller resource that pulls events for you. If you remove EventBridge from the equation and use an Event Source Mapping, you can pause the flow of messages to the Lambda consumer with its enabled property:

    docs: Set to true to enable the event source mapping. Set to false to stop processing records. Lambda keeps track of the last record processed and resumes processing from that point when the mapping is reenabled.

    The UpdateEventSourceMapping API sets the enabled property:

    aws lambda update-event-source-mapping --uuid <mapping-uuid> --enabled false
    

    Option 2: Streams -> EventBridge -> Lambda (with archive and replay)

    If you really need the EventBridge integration, you can temporarily disable the rule that triggers your Lambda, then use the EventBridge archive and replay functionality to catch up when ready. You take responsibility for determining which events need reprocessing. This will be easier if your application is idempotent.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search