Lambda event filter by content inside array

0

I'm trying to create a Lambda Event Filter but got stuck on how to do this. I'd like to filter by the content of the body of the message. The problem is: this content is inside an array. Here is an exemple of what I'm trying to do: The body of the message:

{
  "infoA": "foo",
  "infoB": [
    {
      "infoC": "bar",
      "infoD": "someStuff"
    }
  ]
}

So I'd like to apply a filter for that lambda execute only when 'infoC' == 'bar'(my infoB list will always have only one item). My lambda is subscribed to a SQS, so this is why my filter starts with body key. I've already tried the following filter patterns, without success:

{"body": {"infoB": {"infoC": ["bar"]} } }
{"body": {"infoB": [{"infoC": ["bar"]}] } }

None of this actually worked. On the AWS Lambda documentation, I didn't find information about this kind of filtering (a list inside the body of the message).

I found here that it is possible to filter if any object of the list that has "infoC" = "bar". That would work for me, but didn't find the documentation that explains this anyfilter

  • Why not send the events to event bridge and parse it out through rules?

질문됨 2년 전753회 조회
1개 답변
0

I would recommend sending it to event bridge parsing it there and then only sending the requests that match to the lambda. However you can use SNS filtering. It should work.

Event bridge https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-transform-target-input.html

SNS Filtering https://docs.aws.amazon.com/sns/latest/dg/example-filter-policies.html

Take a look at the JSON being sent to SNS and use the example to parse it out.

Evan
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠