

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# AWS IoT 規則動作
<a name="iot-rule-actions"></a>

AWS IoT 規則動作指定呼叫規則時要執行的動作。您可以定義動作，將資料傳送至 Amazon DynamoDB 資料庫、將資料傳送至 Amazon Kinesis Data Streams、叫用 AWS Lambda 函數等。 AWS IoT 支援下列動作， AWS 區域 其中提供動作的服務。


| 規則動作 | Description | API 中的名稱 | 
| --- | --- | --- | 
| [Apache Kafka](apache-kafka-rule-action.md) | 將訊息傳送至 Apache Kafka 叢集。 | kafka | 
| [CloudWatch 警示](cloudwatch-alarms-rule-action.md) | 變更 Amazon CloudWatch 警示的狀態。 | cloudwatchAlarm | 
| [CloudWatch Logs](cloudwatch-logs-rule-action.md) | 將訊息傳送至 Amazon CloudWatch Logs。 | cloudwatchLogs | 
| [CloudWatch 指標](cloudwatch-metrics-rule-action.md) | 將訊息傳送至 CloudWatch 指標。 | cloudwatchMetric | 
| [DynamoDB](dynamodb-rule-action.md) | 將訊息傳送至 DynamoDB 表格。 | dynamoDB | 
| [DynamoDBv2](dynamodb-v2-rule-action.md) | 將訊息資料傳送至 DynamoDB 表格中的多個欄。 | dynamoDBv2 | 
| [Elasticsearch](elasticsearch-rule-action.md) | 將訊息傳送至 OpenSearch 端點。 | OpenSearch | 
| [HTTP](https-rule-action.md) | 將訊息發佈至 HTTPS 端點。 | http | 
| [AWS IoT Events](iotevents-rule-action.md) | 傳送訊息至 AWS IoT Events 輸入。 | iotEvents | 
| [AWS IoT SiteWise](iotsitewise-rule-action.md) | 傳送訊息資料至 AWS 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](location-rule-action.md) | 將位置資料傳送至 Amazon Location Service。 | location | 
| [OpenSearch](opensearch-rule-action.md) | 將訊息傳送至 Amazon OpenSearch Service 端點。 | OpenSearch | 
| [重新發佈](republish-rule-action.md) | 可在另一個 MQTT 主題上重新發佈訊息。 | republish | 
| [S3](s3-rule-action.md) | 將訊息存放於 Amazon Simple Storage Service (Amazon S3) 儲存貯體中。 | s3 | 
| [Salesforce IoT](salesforce-iot-rule-action.md) | 傳送訊息至 Salesforce IoT 輸入串流。 | 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 | 
| [步驟函數](stepfunctions-rule-action.md) | 啟動 AWS Step Functions 狀態機器。 | stepFunctions | 
| [Timestream](timestream-rule-action.md) | 將訊息傳送至 Amazon Timestream 資料庫表格。 | timestream | 

**備註**  
在與其他服務資源 AWS 區域 相同的 中定義規則，以便規則動作可以與該資源互動。
如果發生間歇性錯誤， AWS IoT 規則引擎可能會多次嘗試執行動作。若所有嘗試都失敗了，則該訊息將遭捨棄，而且可在您的 CloudWatch Logs 中取得錯誤。您可以為失敗發生之後調用的每一個規則指定一個錯誤動作。如需詳細資訊，請參閱[錯誤處理 (錯誤動作)](rule-error-handling.md)。
某些規則動作會啟動服務中與 AWS Key Management Service (AWS KMS) 整合的動作，以支援靜態資料加密。如果您使用客戶受管 AWS KMS key (KMS 金鑰） 加密靜態資料，服務必須具有代表發起人使用 KMS 金鑰的許可。若要了解如何管理客戶受管 KMS 金鑰的許可，請參閱適當服務指南中的資料加密主題。如需客戶受管 KMS 金鑰的詳細資訊，請參閱《AWS Key Management Service 開發人員指南》**中的 [AWS Key Management Service 概念](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html)。  
您可以在錯誤動作的 SQL 陳述式中使用任何[函數](iot-sql-functions.md)或[替代範本](https://docs.aws.amazon.com//iot/latest/developerguide/iot-substitution-templates.html)，包括外部函數：[https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-func-aws-lambda](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-func-aws-lambda)、[https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-dynamodb](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-dynamodb)、[https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-registry_data)、[https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-thing-shadow](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-thing-shadow)[https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-secret](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-get-secret)、[https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-machine-learning](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-function-machine-learning)、 和 [https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-decode-base64](https://docs.aws.amazon.com//iot/latest/developerguide/iot-sql-functions.html#iot-sql-decode-base64)。如果錯誤動作需要呼叫外部 函數，則叫用錯誤動作可能會導致外部函數產生額外的帳單。