简体   繁体   English

如何在 AWS SQS 中创建此事件过滤器

[英]How to create this event filter in AWS SQS

This is the real data structure of my current json data, it contains [] in the data in the first place.这是我当前json数据的真实数据结构,它首先包含数据中的[]

{"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.所以,基本上我只想要来自 SQS 的文本消息类型数据,但现在我不知道过滤器应该是什么。

If you are using yaml in serverless, I´d try this:如果您在无服务器中使用 yaml,我会试试这个:

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"}如果有帮助,我有一个类似的场景:在我的例子中,我希望仅当在 SQS 消息正文中时触发 function,字段“type”的值为“create”或“delete”}

In my case, the next code worked:就我而言,下一个代码有效:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM