

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# IoTRule
<a name="sam-property-function-iotrule"></a>

描述 `IoTRule` 事件源类型的对象。

创建用于声明 AWS IoT 规则的[https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html)资源。有关更多信息，请参阅 [CloudFormation 文档](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iot-topicrule.html)

## 语法
<a name="sam-property-function-iotrule-syntax"></a>

要在 AWS Serverless Application Model (AWS SAM) 模板中声明此实体，请使用以下语法。

### YAML
<a name="sam-property-function-iotrule-syntax.yaml"></a>

```
  [AwsIotSqlVersion](#sam-function-iotrule-awsiotsqlversion): String
  [Sql](#sam-function-iotrule-sql): String
```

## Properties
<a name="sam-property-function-iotrule-properties"></a>

 `AwsIotSqlVersion`   <a name="sam-function-iotrule-awsiotsqlversion"></a>
评估规则时使用的 SQL 规则引擎的版本。  
*类型*：字符串  
*必需*：否  
*CloudFormation 兼容性*：此属性直接传递给`AWS::IoT::TopicRule TopicRulePayload`资源的`[AwsIotSqlVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iot-topicrule-topicrulepayload.html#cfn-iot-topicrule-topicrulepayload-awsiotsqlversion)`属性。

 `Sql`   <a name="sam-function-iotrule-sql"></a>
用于查询主题的 SQL 语句。有关更多信息，请参阅《AWS IoT 开发人员指南》**中的[AWS IoT SQL 参考](https://docs.aws.amazon.com/iot/latest/developerguide/iot-rules.html#aws-iot-sql-reference)。  
*类型*：字符串  
*是否必需*：是  
*CloudFormation 兼容性*：此属性直接传递给`AWS::IoT::TopicRule TopicRulePayload`资源的`[Sql](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-iot-topicrule-topicrulepayload.html#cfn-iot-topicrule-topicrulepayload-sql)`属性。

## 示例
<a name="sam-property-function-iotrule--examples"></a>

### IoT 规则
<a name="sam-property-function-iotrule--examples--iot-rule"></a>

IoT 规则示例

#### YAML
<a name="sam-property-function-iotrule--examples--iot-rule--yaml"></a>

```
IoTRule:
  Type: IoTRule
  Properties:
    Sql: SELECT * FROM 'topic/test'
```