Filtering dynamodb events to trigger Lambda

0

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.

rrrpdx
已提问 1 年前282 查看次数
1 回答
0

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
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则