Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Amazon EventBridge: Match an object inside of an array

I've stuck the problem with defining a rule for matching my events. Googled, tested.

Let's say, we've the following event which contains the object user in the array events:

{
    "version": "0",
    "...": "...",
    "detail": {
        "events": [
            {
                "user": {
                    "id": "5efdee60b48e7c1836078290"
                }
            }
        ]
    }
}

Is there any way to match the user.id in an EventBus rule? I've already tried to use the following rule which is not valid:

{
  "detail": {
    "events": [
      {
        "user": {
          "id": [
            "5efdee60b48e7c1836078290"
          ]
        }
      }
    ]
  }
}

then,

{
  "detail": {
    "events[0]": {
      "user": {
        "id": [
          "5efdee60b48e7c1836078290"
        ]
      }
    }
  }
}

also no effect.

I don't want to give up, but I'm tired with it ;)

like image 293
dobeerman Avatar asked Jan 24 '23 22:01

dobeerman


2 Answers

This pattern should work to match this event:

{
  "detail": {
    "events": {
      "user": {
        "id": [
          "5efdee60b48e7c1836078290"
        ]
      }
    }
  }
}
like image 151
Tom M Avatar answered Feb 11 '23 12:02

Tom M


Today, EventBridge only supports matching simple values (string, integer, boolean, null) with an array. You can read more in the service documentation.

like image 37
Den Delimarsky Avatar answered Feb 11 '23 14:02

Den Delimarsky