When you create an event rule, EventBridge routes events in the standard CloudEvents 1.0 format to event targets. By default, the full event is forwarded as-is. If the target requires a different format or only a subset of the event data, you can configure a transformation method to extract and reshape the event content before delivery.
Four transformation methods are available:
| Method | Description | Typical use case |
|---|---|---|
| Complete Event | Forward the full event with no changes | Pass the raw event to a target that can parse CloudEvents directly |
| Partial Event | Extract a single field using a JSONPath expression | Pull one specific value, such as a resource name or status |
| Fixed Value | Route a static value; the event acts purely as a trigger | Trigger a downstream action that does not depend on event content |
| Template | Extract multiple fields into variables and compose a custom output | Build a notification message or restructure the payload for the target |
How it works
Each transformation follows two phases:
Extract -- Read specific fields from the incoming CloudEvents event using JSONPath expressions (for example,
$.data.name).Compose -- Assemble the extracted values into the output format defined by the transformation method, then deliver the result to the event target.
The method you choose determines which phases apply:
| Method | Extract phase | Compose phase |
|---|---|---|
| Complete Event | Skipped | Passes the full event unchanged |
| Partial Event | Extracts a single field via JSONPath | Returns the extracted value |
| Fixed Value | Skipped | Returns a static value you define |
| Template | Extracts multiple fields into named variables | Substitutes variables into a template |
Sample event
All examples in this topic use the following CloudEvents event as input:
{
"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
}
}Complete Event
EventBridge routes the full event to the target with no changes. The output is identical to the input shown in Sample event.
Use this method when the downstream target can parse the full CloudEvents payload directly.
Partial Event
EventBridge extracts a single value from the event using a JSONPath expression and routes only that value to the target.
Example
| JSONPath expression | Output |
|---|---|
$.data.name | test |
Partial Event supports only one JSONPath expression per rule. The extracted value can be up to 10,240 characters in length.
Fixed Value
The event acts purely as a trigger. EventBridge routes a static value that you define to the target, regardless of the event content.
Example
| Fixed value | Output |
|---|---|
test1 | test1 |
The fixed value can be up to 10,240 characters in length.
Template
Template is the most flexible method. It works in two steps:
Define variables -- Map JSONPath expressions to named variables.
Write a template -- Reference the variables with
${variable_name}syntax to compose the output.
Variable definition example
{
"name": "$.data.name",
"state": "$.data.state"
}This creates two variables: ${name} (resolves to "test") and ${state} (resolves to "RUNNING") when the data field contains {"name": "test", "state": "RUNNING"}.
Template format options
Templates support three output formats, compared below using the variables defined above.
| 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 can also hold fixed values. For example, the following variable definition includes a constant string:
{
"name": "$.data.name",
"constant": "Please deal with it timely."
}With the template The instance is broken, which name is ${name}, ${constant}, the output is:
The instance is broken, which name is test, Please deal with it timely.Limitations
| Constraint | Limit |
|---|---|
| Variable structure | Flat key-value pairs only. Nested structures are not supported. |
| Variable value length | Up to 10,240 characters |
| Template length | Up to 10,240 characters |
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| JSONPath returns no value | The path does not match any field in the event. | Verify the JSONPath expression against the actual event structure. Check for typos in field names. |
| Output exceeds character limit | The extracted value or template exceeds 10,240 characters. | Reduce the scope of the extraction or simplify the template. |
| Template variable not replaced | The variable name in the template does not match the variable definition. | Confirm that the ${variable_name} in the template exactly matches a key in the variable definition JSON. |
| Unexpected output format | Variables are defined with nested JSON objects. | Flatten the variable definition. Nested structures are not supported. |