-
Notifications
You must be signed in to change notification settings - Fork 35
/
rule.yml
196 lines (196 loc) · 8.2 KB
/
rule.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
ROSTemplateFormatVersion: '2015-09-01'
Description:
zh-cn: 创建物联网规则与动作,支持数据筛选、转发至MNS等服务,涵盖自定义与设备状态主题,可配置错误数据处理。
en: Create IoT rules and actions, supporting data filtering and forwarding to services
such as MNS, encompassing custom and device status topics, with configurable error
data handling.
Parameters:
Name:
Type: String
Description: The name of the rule. The name must be 1 to 30 characters in length
and can contain English letters, digits, underscores (_), and hyphens (-). Chinese
language is also supported. Each Chinese symbol occupies 2 characters.
TopicType:
Type: Number
Description: '0: The topic is a basic communication topic or TSL-based communication
topic. 1: The topic is a custom topic. 2: The topic is used to submit device
status changes. Syntax: /as/mqtt/status/${productKey}/${deviceName}.'
Default: 0
IotInstanceId:
Type: String
Description: The ID of the instance. This parameter is not required for public
instances. However, the parameter is required for the instances that you have
purchased.
Default: null
ResourceGroupId:
Type: String
Description: The ID of the resource group to which the rule is assigned. You can
view the resource group information in the Resource Management console. If
you do not specify this parameter, the rule is assigned to the default resource
group.
Default: null
ShortTopic:
Type: String
Description: 'The topic to which this rule is applied. Syntax: ${deviceName}/topicShortName.
${deviceName}specifies the name of the device, and topicShortNamespecifies the
custom name of the topic. Basic communication topics or Thing Specification
Language (TSL)-based communication topics. Syntax: ${deviceName}/topicShortName.
You can replace ${deviceName} with the + wildcard. The wildcard indicates that
the topic applies to all devices under the product. Valid values of topicShortName:
/thing/event/property/post: submits the property data of a device. /thing/event/${tsl.event.identifier}/post:
submits the event data of a device.${tsl.event.identifier} specifies the identifier
of an event in the TSL. /thing/lifecycle: submits device lifecycle changes.
/thing/downlink/reply/message: sends a response to a request from IoT Platform.
/thing/list/found: submits the data when a gateway detects a new sub-device.
/thing/topo/lifecycle: submits device topology changes. /thing/event/property/history/post:
submits historical property data of a device. /thing/event/${tsl.event.identifier}/post:
submits the historical event data of a device.${tsl.event.identifier}specifies
the identifier of an event in the TSL. /ota/upgrade: submits OTA update status.
/ota/version/post: submits OTA module versions. /thing/deviceinfo/update: submits
device tag changes. /edge/driver/${driver_id}/point_post: submits pass-through
data from Link IoT Edge.${driver_id} specifies the ID of the driver that a device
uses to access Link IoT Edge. ${packageId}/${jobId}/ota/job/status: submits
the status of OTA update batches. This topic is a basic communication topic.
${packageId}specifies the ID of the firmware. ${jobId}specifies the ID of the
update batch. Custom topics. Example:${deviceName}/user/get. You can call
theQueryProductTopicoperation to view all custom topics of the product. When
you specify a custom topic, you can use the + and # wildcards. You can replace
${deviceName} with the+ wildcard. The wildcard indicates that the topic applies
to all devices under the product. You can replace the fields that follow ${deviceName}
with /user/#. The # wildcard indicates that the topic applies whatever values
are specified for the fields that follow/user. For more information about how
to use wildcards, see Wildcards in topics. Topic that is used to submit device
status changes: ${deviceName}. You can use the+wildcard. In this case, the
status changes of all devices under the product are submitted.'
Default: null
Select:
Type: String
Description: The SQL SELECT statement that you want to execute. For more information,
seeSQL expressions.
Default: null
DataType:
Type: String
Description: 'The format of the data to be processed by the rule. You must specify
the format of device data to be processed for this parameter. Valid values: JSON:
JSON data BINARY: binary data'
Default: null
RuleDesc:
Type: String
Description: The description of the rule. The description can be up to 100 characters
in length. Each Chinese symbol occupies 1 characters.
Default: null
Where:
Type: String
Description: The condition that is used to trigger the rule. For more information,
seeSQL expressions.
Default: null
ProductKey:
Type: String
Description: The ProductKey of the product to which the rule applies.
Default: null
ErrorActionFlag:
Type: Boolean
Description: |-
Indicates whether the rule action forwarded error operation data. Error operation
data indicates that the rule engine failed to forward data from the IoT Platform topic
to the destination cloud service. A data forwarding failure indicates that forwarding
retries also failed. Valid values:
true: forwards error operation data.
false: forwards normal data instead of error operation data.
Default value: false.
Default: false
AllowedValues:
- true
- false
RuleActionType:
Type: String
Description: |-
The type of the rule action. Valid values:
MNS: forwards data in the topics that have been processed by the rule engine to Message
Service (MNS) for message transmission.
FC: forwards data in the topics that have been processed by the rule engine to Function
Compute for event computing.
REPUBLISH: forwards data in the topics that have been processed by the rule engine to another
IoT Platform topic.
AMQP: forwards data to AMQP consumer groups.
OTS: forwards data in the topics that have been processed by the rule engine to Table
Store for NoSQL data storage.
Note
Rules of the binary data format (the DataType parameter is set toBINARY) do not support forwarding data to Table Store.
Destination Alibaba Cloud services that are supported by the rule engine vary based
on regions. For more information about the regions and destination cloud services
that are supported by the rule engine, see Regions and zones.
Default: MNS
AllowedValues:
- AMQP
- DATAHUB
- FC
- MNS
- ONS
- OTS
- REPUBLISH
TopicName:
Type: String
Resources:
IotRule:
Type: ALIYUN::IOT::Rule
Properties:
TopicType:
Ref: TopicType
IotInstanceId:
Ref: IotInstanceId
ResourceGroupId:
Ref: ResourceGroupId
ShortTopic:
Ref: ShortTopic
Select:
Ref: Select
DataType:
Ref: DataType
RuleDesc:
Ref: RuleDesc
Where:
Ref: Where
ProductKey:
Ref: ProductKey
Name:
Ref: Name
Topic:
Type: ALIYUN::MNS::Topic
Properties:
TopicName:
Ref: TopicName
RuleAction:
Type: ALIYUN::IOT::RuleAction
Properties:
ErrorActionFlag:
Ref: ErrorActionFlag
Type:
Ref: RuleActionType
IotInstanceId:
Ref: IotInstanceId
Configuration:
Fn::Sub: '{"themeName": "${TopicName}", "regionName": "${ALIYUN::Region}", "role":
{"roleArn": "acs:ram::${ALIYUN::TenantId}:role/aliyuniotaccessingmnsrole",
"roleName": "AliyunIOTAccessingMNSRole"}}'
RuleId:
Fn::GetAtt:
- IotRule
- RuleId
DependsOn:
- IotRule
- Topic
Outputs:
RuleId:
Description: The ID of the rule. The rule ID is generated by the rules engine
if the call was successful.
Value:
Fn::GetAtt:
- IotRule
- RuleId
ActionId:
Description: 'The ID of the rule action. '
Value:
Fn::GetAtt:
- IotRule
- ActionId