Background information
EventBridge supports the following event transformation methods:
Complete Event
If you specify Complete Event as the transformation method, EventBridge does not transform an event and routes the complete event in the CloudEvents format to the event target. The following table describes a sample event for which the Complete Event transformation method is used.
Event before transformation | Transformation method | Event after transformation |
{
"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 | {
"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
}
}
|
Partial Event
If you specify Partial Event as the transformation method, EventBridge extracts fields from an event in the CloudEvents format by using JSONPath and routes the specified content of the event to the event target. The following table describes a sample event for which the Partial Event transformation method is used.
Event before transformation | Transformation method | Event after transformation |
{
"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
}
}
| Partial Event $.data.name
Note You can define only one variable if you use the Partial Event transformation method. value: The value can be up to 10,240 characters in length.
| test
|
Fixed Value
If you specify Fixed Value as the transformation method, an event only serves as a trigger. EventBridge routes fixed values in an event to the event target, regardless of the event content. The following table describes a sample event for which the Fixed Value transformation method is used.
Event before transformation | Transformation method | Event after transformation |
{
"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
}
}
| Fixed Value test1
Note value: The value can be up to 10,240 characters in length. | test1
|
Template
If you specify Template as the transformation method, EventBridge extracts fields from an event in the CloudEvents format by using JSONPath, stores the values in variables, and then routes the event in the format that is defined in the template to the event target. The following table describes a sample event for which the Template transformation method is used.
Event before transformation | Transformation method | Event after transformation |
{
"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
}
}
| Template Variable {
"name":"$.data.name",
"constant":"Please deal with it timely."
}
Note The value extracted by JSONPath can be a variable or a fixed value. Nested structures are not supported when you define variables. value: The value can be up to 10,240 characters in length.
Template The instance is broken, which name is ${name}, ${constant}
Note template: The value can be up to 10,240 characters in length.
| The instance is broken, which name is test, Please deal with it timely.
|
You can specify a custom template in the string or JSON format, transform an event based on the template, and route the event to an event target. EventBridge supports the following types of templates:
Table 1. Simple stringEvent before transformation | Transformation method | Event after transformation |
{
"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"
}
}
| Template | "name test is in RUNNING"
|
Table 2. Simple JSONEvent before transformation | Transformation method | Event after transformation |
{
"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"
}
}
| Template Variable {
"name":"$.data.name",
"state":"$.data.state"
}
Template {
"name":"${name}",
"state":"${state}"
}
| {
"name":"test",
"state":"RUNNING"
}
|
Table 3. JSON that includes variables and fixed valuesEvent before transformation | Transformation method | Event after transformation |
{
"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"
}
}
| Template Variable {
"name":"$.data.name",
"state":"$.data.state"
}
Template {
"name":"${name}",
"state":[
9,
"${state}",
true
],
"Transformed":"Yes"
}
| {
"name":"test",
"state":[
9,
"RUNNING",
true
],
"Transformed":"Yes"
}
|