AWS stream and filter patterns – When value is not null

I have a dynamodb and when one record is deleted, a lambda is called. My question is pretty simple as I’m interested only to those records that have a parameter different from null and it’s weird but I wasn’t able to find it anywhere neither in the official doc. It doesn’t look like an edge case so I’m quite sure it’s possible to do it.

Example, when a record is deleted the event is something like that:

{
  "Records": [
    {
      "eventName": "REMOVE",
      "dynamodb": {
        "Keys": { ... },
        "OldImage": {
          "pk": {
            "S": "mock_pk"
          },
          "address": {
            "NULL": true
          }
        }
      }
    }
  ]
}

My filter pattern instead:

{
  "eventName": ["REMOVE"],
  "dynamodb": {
    "OldImage": {
      "pk": {
        "S": [{ "prefix": "REG" }]
      },
      "address": {
        "S": [{ "anything-but": [null] }]
      }
    }
  }
}

But I’ve got this error:

Resource handler returned message: "Invalid request provided: Invalid filter pattern definition.

Seems like “anything-but” is not possible to use for this case and I rather not doing it in the code if there is the possibility.

Leave a Comment