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.
                        
There's a couple of issues at play here.
First and foremost a String
Scannot be null in DynamoDB, as DynamoDB maintains a separate Null bool:"NULL": true. So your request should not be anything-but, but insteadexists, as you only want to know if the value exists as a String.The exception
Resource handler returned message: "Invalid request provided: Invalid filter pattern definitionis likely caused by a syntax error and not the use ofanything-but.