EventBridge transforms events from the standard CloudEvents 1.0 format into the structure that an event target expects before routing them. Four transformation methods are available: Complete Event, Partial Event, Fixed Value, and Template.
How event transformation works
When an event rule routes an event to a target, EventBridge applies the specified transformation method. Each method controls what portion of the original event reaches the target and in what format:
| Method | Behavior | When to use |
|---|---|---|
| Complete Event | Passes the entire CloudEvents payload unchanged. | The target accepts full CloudEvents payloads. |
| Partial Event | Extracts a single field using a JSONPath expression. | The target needs only one value from the event. |
| Fixed Value | Sends a static value, ignoring event content. The event acts purely as a trigger. | The target needs a constant payload regardless of event content. |
| Template | Extracts fields into variables using JSONPath, then assembles a custom output from a template. | The target requires a restructured payload. |
Constraints
| Method | Constraint | Limit |
|---|---|---|
| Partial Event | Number of JSONPath expressions per transformation | 1 |
| Partial Event | Extracted value length | 10,240 characters |
| Fixed Value | Value length | 10,240 characters |
| Template | Variable nesting | Not supported |
| Template | Each variable value length | 10,240 characters |
| Template | Template length | 10,240 characters |
Complete Event
The entire CloudEvents payload is routed to the target without modification.
Input event:
{
"id": "7adc8c1a-645d-4476-bdef-5d6fb57f****",
"source": "acs.oss",
"specversion": "1.0",
"type": "oss:ObjectCreated:PostObject",
"datacontenttype": "application/json",
"dataschema": "http://example.com/test.json",
"subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg",
"time": "2020-08-17T16:04:46.149Asia/Shanghai",
"aliyuneventbusname": "demo-bus",
"aliyunregionid": "Shanghai",
"data": {
"name": "test",
"scope": 100
}
}Output: Identical to the input event. No fields are added, removed, or modified.
Partial Event
Extracts a single field from the CloudEvents payload using a JSONPath expression and routes only that value to the target.
Example: Extract the name field from the event data.
JSONPath expression:
$.data.nameInput event data:
{"name": "test", "scope": 100}Output:
test
Fixed Value
Routes a static value to the target, regardless of event content. The event serves only as a trigger.
Example:
Fixed value:
test1Output:
test1
Regardless of the event content, the output is always the fixed value.
Template
Template transformation works in two steps:
Define variables -- Use JSONPath expressions to extract values from the event and assign them to named variables.
Write a template -- Reference the variables using
${variable_name}syntax to compose the output.
Step 1: Define variables
Map variable names to JSONPath expressions. Each expression extracts a value from the CloudEvents payload:
{
"name": "$.data.name",
"state": "$.data.state"
}A variable value can also be a fixed string instead of a JSONPath expression:
{
"name": "$.data.name",
"constant": "Please deal with it timely."
}Step 2: Write a template
Reference the defined variables in a template string or JSON structure using ${variable_name}:
The instance is broken, which name is ${name}, ${constant}Output:
The instance is broken, which name is test, Please deal with it timely.Template output formats
Templates support three output formats: simple string, simple JSON, and JSON with mixed types. The following examples all use this input event:
{
"id": "7adc8c1a-645d-4476-bdef-5d6fb57f****",
"source": "acs.oss",
"specversion": "1.0",
"type": "oss:ObjectCreated:PostObject",
"datacontenttype": "application/json",
"dataschema": "http://example.com/test.json",
"subject": "acs:oss:cn-hangzhou:1234567:xls-papk/game_apk/123.jpg",
"time": "2020-08-17T16:04:46.149Asia/Shanghai",
"aliyuneventbusname": "demo-bus",
"aliyunregionid": "Shanghai",
"data": {
"name": "test",
"state": "RUNNING"
}
}With these variables defined:
{
"name": "$.data.name",
"state": "$.data.state"
}| Format | Template | Output |
|---|---|---|
| Simple string | "name ${name} is in ${state}" | "name test is in RUNNING" |
| Simple JSON | {"name": "${name}", "state": "${state}"} | {"name": "test", "state": "RUNNING"} |
| JSON with variables and fixed values | {"name": "${name}", "state": [9, "${state}", true], "Transformed": "Yes"} | {"name": "test", "state": [9, "RUNNING", true], "Transformed": "Yes"} |
Variables, static values, and mixed types (strings, numbers, booleans) can coexist in a single template.