Background information
EventBridge supports the following transformation methods:
Complete event
If you select complete event as the transformation method, EventBridge does not transform the event and routes a complete event in the CloudEvents format to an event target. The following table describes examples of events before and after complete event transformation.
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 select partial event as the transformation method, EventBridge extracts fields from an event in the CloudEvents format by using JSONPath and routes the specified part of the event to an event target. The following table describes examples of events before and after partial event transformation.
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 Partial event transformation supports only one variable. value: The value can be up to 10,240 characters in length.
| test
|
Constant
If you select constant as the transformation method, EventBridge routes constants in an event to an event target, regardless of what content the event contains. The following table describes examples of events before and after constant transformation.
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
}
}
| Constant test1
Note value: The value can be up to 10,240 characters in length. | test1
|
Template
You can create a custom template and define the variables in the template. If you select 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 an event target. The following table describes examples of events before and after template transformation.
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 values extracted by using JSONPath can be variables or constants. A nested structure is 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 A template can be up to 10,240 characters in length.
| The instance is broken, which name is test, Please deal with it timely.
|
You can customize a 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 | Type conversion | 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 | Type conversion | 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 constantsEvent before transformation | Type conversion | 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"
}
|
Table 4. Nested JSONEvent before transformation | Transformation method | Event after transformation |
{
"id": "45ef4dewdwe1-7c35-447a-bd93-fab****",
"source": "acs.imm",
"specversion": "1.0",
"subject": "acs.imm:cn-hangzhou:123456789098****:215672",
"time": "2020-11-19T21:04:41+08:00",
"type": "imm:FileMeta:Index",
"aliyunaccountid": "123456789098****",
"aliyunpublishtime": "2020-11-19T21:04:42.179PRC",
"aliyuneventbusname": "default",
"aliyunregionid": "cn-hangzhou",
"aliyunpublishaddr": "172.25.XX.XX",
"data": {
"ProjectName": "test_project",
"DatasetName": "test_dataset",
"RequestId": "D2A3AE88-D17C-4CCC-B149-6651115C****",
"StartTime": "2021-07-22T14:03:15.489885+08:00",
"EndTime": "2021-07-22T14:05:15.489885+08:00",
"Message": "InvalidParameter",
"Success": false,
"Files": [
{
"URI": "oss://bucket/file",
"CustomId": "defaultId",
"CustomLabels": {
"Key1": "Val1",
"Key2": "Val2"
},
"Error": "InternalError"
}
]
}
}
| Template Variable {
"ProjectName":"$.data.ProjectName",
"Files":"$.data.Files"
}
Template {
"ProjectName":"${ProjectName}",
"Files":${Files}
}
| {
"ProjectName":"test_project",
"Files": [
{
"URI": "oss://bucket/file",
"CustomId": "defaultId",
"CustomLabels": {
"Key1": "Val1",
"Key2": "Val2"
},
"Error": "InternalError"
}
]
}
|