skip to Main Content

Here is a modified version of an Event type I am receiving in my handler for a lambda function with a DynamoDB someTableName table trigger that I logged using cargo lambda.

Event { 
    records: [
        EventRecord { 
            change: StreamRecord { 
                approximate_creation_date_time: ___ 
                keys: {"id": String("___")}, 
                new_image: {
                   ....
                    "valid": Boolean(true), 
                }, 
               ...
            }, 
            ...
            event_name: "INSERT", 
            event_source: Some("aws:dynamodb"), 
            table_name: None 
        }
    ] 
}

Goal: Correctly filter with event_name=INSERT && valid=false

I have tried a number of options, for example;
{"eventName": ["INSERT"]}
While the filter is added correctly, it does not trigger the lambda on item inserted.

Q1) What am I doing incorrectly here?

Q2) Why is table_name returning None? The lambda function is created with a specific table name as trigger. The returned fields are returning an option (Some(_)) so I’m asssuming it returns None if the table name is specified on lambda creation, but seems odd to me?

Q3) From AWS Management Console > Lambda > … > Trigger Detail, I see the following (which is slightly different from my code mentioned above), where does "key" come from and what does it represent in the original Event?

enter image description here

2

Answers


  1. The attribute name is actually eventName, so your filter should look like this:

    {"eventName": ["INSERT"]}
    
    Login or Signup to reply.
  2. Filters must follow the documented syntax for filtering in the Event Source Mapping between Lambda and DynamoDB Streams.

    If you are entering the filter in the Lambda console:

    { "eventName": ["INSERT"], "dynamodb": { "NewImage": {"valid": { "BOOL" : [false]}} } }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search