I have an integration between AWS EventBridge and AWS Lambda. I'm using aws-cdk to create Rule.
Let's say I have EB event in the following format
{
"event": {
"version": "0",
"id": "e7e4d675-1bea-ad19-ffa3-4d6e962e15af",
"detail-type": "SOMETHING_HAPPENED",
"source": "source",
"account": "111111111111",
"time": "2023-02-23T14:52:34Z",
"region": "eu-west-1",
"resources": [],
"detail": {
"data": { "key": "value" },
"metadata": { "correlation-id": "some uuid" }
}
}
}
In my AWS lambda, as an input, I want to omit metadata and set details = nested data but keep other fields
{
"event": {
"version": "0",
"id": "e7e4d675-1bea-ad19-ffa3-4d6e962e15af",
"detail-type": "SOMETHING_HAPPENED",
"source": "source",
"account": "111111111111",
"time": "2023-02-23T14:52:34Z",
"region": "eu-west-1",
"resources": [],
"detail": { "key": "value" }
}
}
The documentation lacks of examples or hidden somewhere.
Is it possible to enrich or replace subset of fields of the original event?
EventBridge Input Transformation is the feature for you.
It does exactly what you need: transforming an event input before it's passed to the consumer.
You can configure it from CloudFormation / Terraform or from the Console UI, in the step "Configure Target" (third step), under the "Additional Settings" -> "Configure target input" section.
Based on your question, your Input Transformer configuration should be something like:
{
"version" : "$.version",
"id" : "$.id",
...and so on...
"detail": "$.detail.data"
}