How to pass matched event AND constant from AWS EventBridge?

290 views Asked by At

I want to invoke a lambda and I want to pass the entire matched event and I want to also pass a constant. I am aware of the input transformer but I don't want to use it because the matched event schema can change.

This is essentially what I am trying to do:

Input path:

{
    "originalEvent": "$"
}

Input Template:

{
    "myConstant": "hey now brown cow"
    "originalEvent": "<originalEvent>"
}

So given the following 2 events:

event 1
{
   "id": "123",
   "detail": {
     "state": "RUNNING",
     "someProp": "someVal"
   }
}
event 2
{
   "id": "456",
   "detail": {
     "state": "FAILED",
     "someOtherProp": "someOtherValue"
   }
}

The expected transformed/generated json that is delivered to the target:

transformed json 1
{
    "myConstant": "hey now brown cow",
    "originalEvent": {
       "id": "123",
       "detail": {
         "state": "RUNNING",
         "someProp": "someVal"
       }
    }
}
transformed json 2
{
    "myConstant": "hey now brown cow",
    "originalEvent": {
       "id": "456",
       "detail": {
         "state": "FAILED",
         "someOtherProp": "someOtherVal"
       }
    }
}

Instead what is actually happening is this:

transformed json 1
{
    "myConstant": "hey now brown cow",
    "originalEvent": "[Object object]"
}
transformed json 2
{
    "myConstant": "hey now brown cow",
    "originalEvent": "[Object object]"
}

I've also tried doing it as it is described here but no dice.

Again - I DO NOT want to re-create the matched json object in the input path/template via $.whatever. I'd have to do that for the entire object which I want to avoid because the schema may be unknown to the event rule. I don't want to have to worry about mapping all of the possible existing properties on the incoming event.

Is this not possible?

1

There are 1 answers

1
Quassnoi On BEST ANSWER

Input path:

{}

Template:

{
  "originalEvent": <aws.events.event.json>,
  "myConstant": "hey now brown cow"
}