Lambda event filter for Json array

0

In the documentation https://docs.aws.amazon.com/lambda/latest/dg/invocation-eventfiltering.html#filtering-syntax it is only mention "Weather": [ { "anything-but": [ "Raining" ] } ]

What I am need is to filter if the array contains a specific value. Example json { "MyKey": "Value", "Number": 12, "References": [ { "Key1": 14 }, { "Key2": 14 } ] }

What would be the filter syntax to check if "Key1" exists ?

asked 10 months ago472 views
1 Answer
0

In EventBridge, your custom payload is always included in the "detail" field, so your actual event will look like:

{
  "detail-type": "MyCustomEvent",
  "source": "aws.partner/salesforce.com/xxxxxxxxxxxx/xxxxxxxxxxx",
  "account": "12345678921",
  "time": "2022-04-06T20:24:01Z",
  "resources": [],
  "detail": {
    "MyKey": "Value",
    "Number": 12,
    "References": [{
      "Key1": 14
    }, {
      "Key2": 14
    }]
  }
}

Your rule should look like this:

{
  "detail": {
    "References": {
      "Key2": [14]
    }
  }
}
profile pictureAWS
EXPERT
Uri
answered 10 months ago
profile picture
EXPERT
reviewed 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions