Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DynamoDB streams filter with nested fields not working

I have a Lambda hooked up to my DynamoDB stream. It is configured to trigger if both criteria are met:

  • eventName = "MODIFY"
  • status > 10

My filter looks as follows:

{"eventName": ["MODIFY"], "dynamodb": {"NewImage": {"status": [{"numeric": [">", 10]}]}}}

If the filter is configured to only trigger if the event name is MODIFY it works, however anything more complicated than that does not trigger my Lambda. The event looks as follows:

{
    "eventID": "ba1cff0bb53fbd7605b7773fdb4320a8",
    "eventName": "MODIFY",
    "eventVersion": "1.1",
    "eventSource": "aws:dynamodb",
    "awsRegion": "us-east-1",
    "dynamodb":
    {
        "ApproximateCreationDateTime": 1643637766,
        "Keys":
        {
            "org":
            {
                "S": "test"
            },
            "id":
            {
                "S": "61f7ebff17afad170f98e046"
            }
        },
        "NewImage":
        {
            "status":
            {
                "N": "20"
            }
        }
    }
}

When using the test_event_pattern endpoint it confirms the filter is valid:

filter = {
    "eventName":  ["MODIFY"],
    "dynamodb": {
        "NewImage": {
            "status":  [ { "numeric": [ ">", 10 ] } ]
        }
    }
}

response = client.test_event_pattern(
    EventPattern=json.dumps(filter),
    Event="{\"id\": \"e00c66cb-fe7a-4fcc-81ad-58eb60f5d96b\", \"eventName\": \"MODIFY\", \"dynamodb\": {\"NewImage\":{\"status\": 20}}, \"detail-type\": \"myDetailType\", \"source\": \"com.mycompany.myapp\", \"account\": \"123456789012\", \"time\": \"2016-01-10T01:29:23Z\", \"region\": \"us-east-1\"}"
)
print(response) >> {'Result': True, 'ResponseMetadata': {'RequestId':...}

Is there something that I'm overlooking? Do DynamoDB filters not work on the actual new image?

like image 299
Nicolas Avatar asked Feb 18 '26 07:02

Nicolas


1 Answers

I realize I'm a bit late to the show, but for anyone else ending up here, DynamoDB event filtering doesn't support the use of numerical operators.

You can read more about it here.

like image 52
fefferoni Avatar answered Feb 21 '26 14:02

fefferoni



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!