EventBridge InputTransformer doesn't work when trying to return Array

0

I have EventBus, which has a rule with certain target. There is an InputTransformer inside the target with the InputPath and InputTemplate. I want the transformation to the Array as a result.

I send custom event to EventBus with the detail field, in which I have desired JSON

{
  "version": "0",
  "id": "9fd93571-3201-4e0d-6cf0-328ff344c9e3",
  "detail-type": "test",
  "source": "foobar",
  "account": "192675374686",
  "time": "2023-10-10T11:22:01Z",
  "region": "us-east-1",
  "resources": [],
  "detail": {
    "address": {
      "field": "888",
      "innerField": {
        "someInnerField": "999"
      }
    }
  }
}

My expected output is the Array, when I try this InputPath and InputTemplate adding the square brackets, it sends it without double quotes, but it does some transformation.

InputPath

{
  "detail": "$.detail"
}

InputTemplate

[{
  "customField": <detail>
}]

Actual Output (Message taken from dead-letter queue which configured with target, it was send there, because of invalid json, which is true)

[{
   "customField": {address:{field:888,innerField:{someInnerField:999}}}
}]

Expected Output

[{
  "customField": {
    "address": {
      "field": "888",
      "innerField": {
        "someInnerField": "999"
      }
    }
  }
}]

What will totally work, but it doesn't work for JSON with a lot of fields

Sure, we can map every field inside InputPath and then put it inside the template via variables. Already checked it, works.

Path

{
  "field": "$.detail.address.field",
  "someInnerField": "$.detail.address.innerField.someInnerField"
}

Template

[{
   "customField": {
     "address": {
       "field": "<field>"
       "innerField": {
         "someInnerField": "<someInnerField>"
       }
     }
   }
}]
Dmytro
asked 7 months ago77 views
No Answers

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