Configuring an input transformer when creating a rule in EventBridge
As part of creating a rule, you can specify an input transformer for EventBridge to use to process matching events prior to sending those event to the specified target. You can configure input transformers for targets that are AWS services or API destinations.
To create a target input transformer as part of a rule
Follow the steps for creating a rule as detailed in Creating rules that react to events in Amazon EventBridge.
In Step 3 - Select target(s), expand Additional settings.
For Configure target input, choose Input transformer in the dropdown.
Click Configure input transformer.
EventBridge displays the Configure input transformer dialog box.
-
In the Sample event section, choose a Sample event type against which you want to test your event pattern. You can choose an AWS event, a partner event, or enter your own custom event.
(Optional) Expand the Example input paths, Templates and Outputs section to see examples of:
How JSON paths are used to define variables that represent event data
How those variables can be used in an input transformer template
The resulting output that EventBridge sends to the target
For more detailed examples of input transformations, see Input transform examples.
-
In the Target input transformer section, define any variables you want to use in the input template.
Variables use JSON path to reference values in the original event source. You can then reference those variables in the input template in order to include data from the original source event in the transformed event that EventBridge passes to the target. You can define up to 100 variables. The input transformer must be valid JSON.
For example, suppose you had chosen AWS event S3 Object Created as your sample event for this input transformer. You could then define the following variables for use in your template:
{ "requester": "$.detail.requester", "key": "$.detail.object.key", "bucket": "$.detail.bucket.name" }
(Optional) You can also choose Copy to copy the input transformer to your device's clipboard.
In the Template section, compose the template you want to use to determine what EventBridge passes to the target.
You can use JSON, strings, static information, variables you've defined as well as reserved variables. For more detailed examples of input transformations, see Input transform examples.
For example, suppose you had defined the variables in the previous example. You could then compose the following template, which references those variables, as well as reserved variables, and static information.
{ "message": "<requester> has created the object \"<key>\" in the bucket \"<bucket>\"", "RuleName": <aws.events.rule-name>, "ruleArn" : <aws.events.rule-arn>, "Transformed": "Yes" }
(Optional) You can also choose Copy to copy the template to your device's clipboard.
-
To test your template, select Generate output.
EventBridge processes the sample event based on the input template, and displays the transformed output generated under Output. This is the information that EventBridge will pass to the target in place of the original source event.
The generated output for the example input template described above would be the following:
{ "message": "123456789012 has created the object "example-key" in the bucket "example-bucket"", "RuleName": rule-name, "ruleArn" : arn:aws:events:us-east-1:123456789012:rule/rule-name, "Transformed": "Yes" }
(Optional) You can also choose Copy to copy the generated output to your device's clipboard.
Select Confirm
Follow the rest of the steps for creating a rule as detailed in Creating rules that react to events in Amazon EventBridge.