

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

# Amazon IoT 规则动作
<a name="iot-rule-actions"></a>

Amazon IoT 规则操作指定调用规则时要执行的操作。您可以定义向亚马逊 DynamoDB 数据库发送数据、向 Amazon Kinesis Data Streams 发送数据、 Amazon Lambda 调用函数等的操作。 Amazon IoT Amazon Web Services 区域 在操作的服务可用时，支持以下操作。


| 规则操作 | 说明 | API 中的名称 | 
| --- | --- | --- | 
| [Apache Kafka](apache-kafka-rule-action.md) | 将消息发送到 Apache Kafka 集群。 | kafka | 
| [CloudWatch 警报](cloudwatch-alarms-rule-action.md) | 更改 Amazon CloudWatch 警报的状态。 | cloudwatchAlarm | 
| [CloudWatch 日志](cloudwatch-logs-rule-action.md) | 向 Amazon CloudWatch Logs 发送消息。 | cloudwatchLogs | 
| [CloudWatch 指标](cloudwatch-metrics-rule-action.md) | 向 CloudWatch 指标发送消息。 | cloudwatchMetric | 
| [DynamoDB](dynamodb-rule-action.md) | 将消息发送到 DynamoDB 表。 | dynamoDB | 
| [迪纳摩 DBv2](dynamodb-v2-rule-action.md) | 将消息数据发送到 DynamoDB 表中的多列。 | dynamoDBv2 | 
| [Elasticsearch](elasticsearch-rule-action.md) | 向 OpenSearch 端点发送消息。 | OpenSearch | 
| [HTTP](https-rule-action.md) | 将消息发布到 HTTPS 端点。 | http | 
| [Amazon IoT Events](iotevents-rule-action.md) | 向 Amazon IoT Events 输入发送消息。 | iotEvents | 
| [Amazon IoT SiteWise](iotsitewise-rule-action.md) | 向 Amazon IoT SiteWise 资产属性发送消息数据。 | iotSiteWise | 
| [Firehose](kinesis-firehose-rule-action.md) | 将消息发送到 Firehose 传输流。 | firehose | 
| [Kinesis Data Streams](kinesis-rule-action.md) | 将消息发送到 Kinesis 数据流。 | kinesis | 
| [Lambda](lambda-rule-action.md) | 使用消息数据作为输入调用 Lambda 函数。 | lambda | 
| [位置](location-rule-action.md) | 向 Amazon Location Service 发送位置数据。 | location | 
| [OpenSearch](opensearch-rule-action.md) | 向亚马逊 OpenSearch 服务终端节点发送消息。 | OpenSearch | 
| [重新发布](republish-rule-action.md) | 在另一个 MQTT 主题上重新发布消息。 | republish | 
| [S3](s3-rule-action.md) | 将消息存储在 Amazon Simple Storage Service（Amazon S3）存储桶中。 | s3 | 
| [Salesforce 物联](salesforce-iot-rule-action.md) | 将消息发送到 Salesforce物联网输入流。 | salesforce | 
| [SNS](sns-rule-action.md) | 将消息发布为 Amazon Simple Notification Service（Amazon SNS）推送通知。 | sns | 
| [SQS](sqs-rule-action.md) | 将消息发送到 Amazon Simple Queue Service（Amazon SQS）队列。 | sqs | 
| [Step Functions](stepfunctions-rule-action.md) | 启动 Amazon Step Functions 状态机。 | stepFunctions | 
| [Timestream](timestream-rule-action.md) | 将消息发送到 Amazon Timestream 数据库表。 | timestream | 

**注意**  
将规则定义 Amazon Web Services 区域 为与其他服务的资源相同，以便规则操作可以与该资源进行交互。
如果出现间歇性错误， Amazon IoT 规则引擎可能会多次尝试执行某项操作。如果所有尝试都失败，则该消息将被丢弃，错误将在您的 CloudWatch 日志中显示。您可以为在发生故障后调用的每条规则指定一个错误操作。有关更多信息，请参阅 [错误处理（错误操作）](rule-error-handling.md)。
某些规则操作会激活与 Amazon Key Management Service (Amazon KMS) 集成的服务中的操作，以支持静态数据加密。如果您使用客户管理 Amazon KMS key （KMS 密钥）对静态数据进行加密，则服务必须有权代表呼叫者使用 KMS 密钥。要了解如何管理客户自主管理型 KMS 密钥的权限，请参阅相应服务指南中的数据加密主题。有关客户自主管理型 KMS 密钥的更多信息，请参阅*《Amazon Key Management Service 开发人员指南》*中的 [Amazon Key Management Service 概念](https://docs.amazonaws.cn/kms/latest/developerguide/concepts.html)。  
可以在错误操作的 SQL 语句中使用任何[函数](iot-sql-functions.md)或[替换模板](https://docs.amazonaws.cn//iot/latest/developerguide/iot-substitution-templates.html)，包括外部函数：[https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-func-aws-lambda](https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-func-aws-lambda)、[https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data](https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data)、[https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-thing-shadow](https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-thing-shadow)、[https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-secret](https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-secret)、[https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-machine-learning](https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-machine-learning)、和[https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-decode-base64](https://docs.amazonaws.cn//iot/latest/developerguide/iot-sql-functions.html#iot-sql-decode-base64)。如果错误操作需要调用外部函数，则调用错误操作可能会导致产生针对外部函数的额外账单。