Filtering dynamodb events to trigger Lambda


Hi, I am trying to trigger a lambda function from a DynamoDB stream, and can't seem to get filtering working correctly. Without filtering the event looks like this:

{'Records': [{'eventID': '8aa2e4c1d77d2596c741c378247ca43d', 'eventName': 'INSERT', 'eventVersion': '1.1', 'eventSource': 'aws:dynamodb', 'awsRegion': 'us-west-2', 'dynamodb': {'ApproximateCreationDateTime': 1682107857.0, 'Keys': {'IngestionID': {'S': 'INGEST_20230421131056'}, 'UserID': {'S': 'us-west-2:7bc59622-687b-41f8-91aa-dd63b566b3a4'}}, 'NewImage': {'IngestionComplete': {'N': '0'}, 'IngestionID': {'S': 'INGEST_20230421131056'}, 'SuccessfulUpload': {'N': '0'}, 'FailedItems': {'N': '0'}, 'FailedUpload': {'N': '0'}, 'UserID': {'S': 'us-west-2:7bc59622-687b-41f8-91aa-dd63b566b3a4'}, 'AbortIngest': {'N': '0'}, 'FailedTranscode': {'N': '0'}, 'TotalItems': {'N': '1'}, 'ItemsProcessed': {'N': '1'}}, 'SequenceNumber': '20422200000000005593358615', 'SizeBytes': 284, 'StreamViewType': 'NEW_AND_OLD_IMAGES'}, 'eventSourceARN': 'arn:aws:dynamodb:us-west-2:241649497082:table/IngestionData/stream/2023-04-21T18:31:57.157'}]}

I would like to trigger my lambda when ItemsProcessed=0... I am using the AWS console (web) to configure the trigger. I have tried the following:

  • { "NewImage": { "ItemsProcessed": {"S":["0"]} } }
  • { "NewImage": { "ItemsProcessed": {"N":["0"]} } }
  • { "dynamodb": { "NewImage": { "ItemsProcessed": [{ "numeric": ["=", 0] }] } }}

but none of these seem to generate triggers... What do I type in the "FilterCriteria" box in the console, to properly filter events? Thx.

asked a year ago327 views
1 Answer

Hi, can you try below?

{ "dynamodb": { "NewImage": { "ItemsProcessed": { "N": [“0”] } } }}

Haven’t tried directly on console, but that or slight modification of it may do the trick. And you may add the eventName as part of field.

Hope it helps ;)

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions