How to create this event filter in AWS SQS

1k views Asked by At

This is the real data structure of my current json data, it contains [] in the data in the first place.

{"events":[{"type":"message","message":{"type":"text"}}]}

So, basically I just want text message type data from SQS, but now I don't know what should the filter be.

1

There are 1 answers

1
Markussen On

If you are using yaml in serverless, I´d try this:

filterPatterns:
    - body: {events: {type: ["message"], message: {type: ["text"]}}}

In case it helps, I had a similar scenario: in my case, I want a function to be triggered only when inside the body of the SQS message, the field "type" has values "create" or "delete"}

In my case, the next code worked:

filterPatterns:
    - body : {type: [create, delete]}