Creates a rule. Creating rules is an administrator-level action. Any user who has permission to create rules will be able to access data processed by the rule.
See also: AWS API Documentation
See ‘aws help’ for descriptions of global parameters.
create-topic-rule
--rule-name <value>
--topic-rule-payload <value>
[--tags <value>]
[--cli-input-json | --cli-input-yaml]
[--generate-cli-skeleton <value>]
--rule-name
(string)
The name of the rule.
--topic-rule-payload
(structure)
The rule payload.
sql -> (string)
The SQL statement used to query the topic. For more information, see AWS IoT SQL Reference in the AWS IoT Developer Guide .
description -> (string)
The description of the rule.
actions -> (list)
The actions associated with the rule.
(structure)
Describes the actions associated with a rule.
dynamoDB -> (structure)
Write to a DynamoDB table.
tableName -> (string)
The name of the DynamoDB table.
roleArn -> (string)
The ARN of the IAM role that grants access to the DynamoDB table.
operation -> (string)
The type of operation to be performed. This follows the substitution template, so it can be
${operation}
, but the substitution must result in one of the following:INSERT
,UPDATE
, orDELETE
.hashKeyField -> (string)
The hash key name.
hashKeyValue -> (string)
The hash key value.
hashKeyType -> (string)
The hash key type. Valid values are “STRING” or “NUMBER”
rangeKeyField -> (string)
The range key name.
rangeKeyValue -> (string)
The range key value.
rangeKeyType -> (string)
The range key type. Valid values are “STRING” or “NUMBER”
payloadField -> (string)
The action payload. This name can be customized.
dynamoDBv2 -> (structure)
Write to a DynamoDB table. This is a new version of the DynamoDB action. It allows you to write each attribute in an MQTT message payload into a separate DynamoDB column.
roleArn -> (string)
The ARN of the IAM role that grants access to the DynamoDB table.
putItem -> (structure)
Specifies the DynamoDB table to which the message data will be written. For example:
{ "dynamoDBv2": { "roleArn": "aws:iam:12341251:my-role" "putItem": { "tableName": "my-table" } } }
Each attribute in the message payload will be written to a separate column in the DynamoDB database.
tableName -> (string)
The table where the message data will be written.
lambda -> (structure)
Invoke a Lambda function.
functionArn -> (string)
The ARN of the Lambda function.
sns -> (structure)
Publish to an Amazon SNS topic.
targetArn -> (string)
The ARN of the SNS topic.
roleArn -> (string)
The ARN of the IAM role that grants access.
messageFormat -> (string)
(Optional) The message format of the message to publish. Accepted values are “JSON” and “RAW”. The default value of the attribute is “RAW”. SNS uses this setting to determine if the payload should be parsed and relevant platform-specific bits of the payload should be extracted. To read more about SNS message formats, see https://docs.aws.amazon.com/sns/latest/dg/json-formats.html refer to their official documentation.
sqs -> (structure)
Publish to an Amazon SQS queue.
roleArn -> (string)
The ARN of the IAM role that grants access.
queueUrl -> (string)
The URL of the Amazon SQS queue.
useBase64 -> (boolean)
Specifies whether to use Base64 encoding.
kinesis -> (structure)
Write data to an Amazon Kinesis stream.
roleArn -> (string)
The ARN of the IAM role that grants access to the Amazon Kinesis stream.
streamName -> (string)
The name of the Amazon Kinesis stream.
partitionKey -> (string)
The partition key.
republish -> (structure)
Publish to another MQTT topic.
roleArn -> (string)
The ARN of the IAM role that grants access.
topic -> (string)
The name of the MQTT topic.
qos -> (integer)
The Quality of Service (QoS) level to use when republishing messages. The default value is 0.
s3 -> (structure)
Write to an Amazon S3 bucket.
roleArn -> (string)
The ARN of the IAM role that grants access.
bucketName -> (string)
The Amazon S3 bucket.
key -> (string)
The object key. For more information, see Actions, resources, and condition keys for Amazon S3 .
cannedAcl -> (string)
The Amazon S3 canned ACL that controls access to the object identified by the object key. For more information, see S3 canned ACLs .
firehose -> (structure)
Write to an Amazon Kinesis Firehose stream.
roleArn -> (string)
The IAM role that grants access to the Amazon Kinesis Firehose stream.
deliveryStreamName -> (string)
The delivery stream name.
separator -> (string)
A character separator that will be used to separate records written to the Firehose stream. Valid values are: ‘n’ (newline), ‘t’ (tab), ‘rn’ (Windows newline), ‘,’ (comma).
batchMode -> (boolean)
Whether to deliver the Kinesis Data Firehose stream as a batch by using `
PutRecordBatch
https://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecordBatch.html`__ . The default value isfalse
.When
batchMode
istrue
and the rule’s SQL statement evaluates to an Array, each Array element forms one record in the `PutRecordBatch
https://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecordBatch.html`__ request. The resulting array can’t have more than 500 records.cloudwatchMetric -> (structure)
Capture a CloudWatch metric.
roleArn -> (string)
The IAM role that allows access to the CloudWatch metric.
metricNamespace -> (string)
The CloudWatch metric namespace name.
metricName -> (string)
The CloudWatch metric name.
metricValue -> (string)
The CloudWatch metric value.
metricUnit -> (string)
The metric unit supported by CloudWatch.
metricTimestamp -> (string)
An optional Unix timestamp .
cloudwatchAlarm -> (structure)
Change the state of a CloudWatch alarm.
roleArn -> (string)
The IAM role that allows access to the CloudWatch alarm.
alarmName -> (string)
The CloudWatch alarm name.
stateReason -> (string)
The reason for the alarm change.
stateValue -> (string)
The value of the alarm state. Acceptable values are: OK, ALARM, INSUFFICIENT_DATA.
cloudwatchLogs -> (structure)
Send data to CloudWatch Logs.
roleArn -> (string)
The IAM role that allows access to the CloudWatch log.
logGroupName -> (string)
The CloudWatch log group to which the action sends data.
elasticsearch -> (structure)
Write data to an Amazon Elasticsearch Service domain.
roleArn -> (string)
The IAM role ARN that has access to Elasticsearch.
endpoint -> (string)
The endpoint of your Elasticsearch domain.
index -> (string)
The Elasticsearch index where you want to store your data.
type -> (string)
The type of document you are storing.
id -> (string)
The unique identifier for the document you are storing.
salesforce -> (structure)
Send a message to a Salesforce IoT Cloud Input Stream.
token -> (string)
The token used to authenticate access to the Salesforce IoT Cloud Input Stream. The token is available from the Salesforce IoT Cloud platform after creation of the Input Stream.
url -> (string)
The URL exposed by the Salesforce IoT Cloud Input Stream. The URL is available from the Salesforce IoT Cloud platform after creation of the Input Stream.
iotAnalytics -> (structure)
Sends message data to an AWS IoT Analytics channel.
channelArn -> (string)
(deprecated) The ARN of the IoT Analytics channel to which message data will be sent.
channelName -> (string)
The name of the IoT Analytics channel to which message data will be sent.
batchMode -> (boolean)
Whether to process the action as a batch. The default value is
false
.When
batchMode
istrue
and the rule SQL statement evaluates to an Array, each Array element is delivered as a separate message when passed by `BatchPutMessage
https://docs.aws.amazon.com/iotanalytics/latest/APIReference/API_BatchPutMessage.html`__ to the AWS IoT Analytics channel. The resulting array can’t have more than 100 messages.roleArn -> (string)
The ARN of the role which has a policy that grants IoT Analytics permission to send message data via IoT Analytics (iotanalytics:BatchPutMessage).
iotEvents -> (structure)
Sends an input to an AWS IoT Events detector.
inputName -> (string)
The name of the AWS IoT Events input.
messageId -> (string)
The ID of the message. The default
messageId
is a new UUID value.When
batchMode
istrue
, you can’t specify amessageId
–a new UUID value will be assigned.Assign a value to this property to ensure that only one input (message) with a given
messageId
will be processed by an AWS IoT Events detector.batchMode -> (boolean)
Whether to process the event actions as a batch. The default value is
false
.When
batchMode
istrue
, you can’t specify amessageId
.When
batchMode
istrue
and the rule SQL statement evaluates to an Array, each Array element is treated as a separate message when it’s sent to AWS IoT Events by calling `BatchPutMessage
https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_BatchPutMessage.html`__ . The resulting array can’t have more than 10 messages.roleArn -> (string)
The ARN of the role that grants AWS IoT permission to send an input to an AWS IoT Events detector. (“Action”:”iotevents:BatchPutMessage”).
iotSiteWise -> (structure)
Sends data from the MQTT message that triggered the rule to AWS IoT SiteWise asset properties.
putAssetPropertyValueEntries -> (list)
A list of asset property value entries.
(structure)
An asset property value entry containing the following information.
entryId -> (string)
Optional. A unique identifier for this entry that you can define to better track which message caused an error in case of failure. Accepts substitution templates. Defaults to a new UUID.
assetId -> (string)
The ID of the AWS IoT SiteWise asset. You must specify either a
propertyAlias
or both analiasId
and apropertyId
. Accepts substitution templates.propertyId -> (string)
The ID of the asset’s property. You must specify either a
propertyAlias
or both analiasId
and apropertyId
. Accepts substitution templates.propertyAlias -> (string)
The name of the property alias associated with your asset property. You must specify either a
propertyAlias
or both analiasId
and apropertyId
. Accepts substitution templates.propertyValues -> (list)
A list of property values to insert that each contain timestamp, quality, and value (TQV) information.
(structure)
An asset property value entry containing the following information.
value -> (structure)
The value of the asset property.
stringValue -> (string)
Optional. The string value of the value entry. Accepts substitution templates.
integerValue -> (string)
Optional. A string that contains the integer value of the value entry. Accepts substitution templates.
doubleValue -> (string)
Optional. A string that contains the double value of the value entry. Accepts substitution templates.
booleanValue -> (string)
Optional. A string that contains the boolean value (
true
orfalse
) of the value entry. Accepts substitution templates.timestamp -> (structure)
The asset property value timestamp.
timeInSeconds -> (string)
A string that contains the time in seconds since epoch. Accepts substitution templates.
offsetInNanos -> (string)
Optional. A string that contains the nanosecond time offset. Accepts substitution templates.
quality -> (string)
Optional. A string that describes the quality of the value. Accepts substitution templates. Must be
GOOD
,BAD
, orUNCERTAIN
.roleArn -> (string)
The ARN of the role that grants AWS IoT permission to send an asset property value to AWS IoTSiteWise. (
"Action": "iotsitewise:BatchPutAssetPropertyValue"
). The trust policy can restrict access to specific asset hierarchy paths.stepFunctions -> (structure)
Starts execution of a Step Functions state machine.
executionNamePrefix -> (string)
(Optional) A name will be given to the state machine execution consisting of this prefix followed by a UUID. Step Functions automatically creates a unique name for each state machine execution if one is not provided.
stateMachineName -> (string)
The name of the Step Functions state machine whose execution will be started.
roleArn -> (string)
The ARN of the role that grants IoT permission to start execution of a state machine (“Action”:”states:StartExecution”).
timestream -> (structure)
The Timestream rule action writes attributes (measures) from an MQTT message into an Amazon Timestream table. For more information, see the Timestream topic rule action documentation.
roleArn -> (string)
The ARN of the role that grants permission to write to the Amazon Timestream database table.
databaseName -> (string)
The name of an Amazon Timestream database.
tableName -> (string)
The name of the database table into which to write the measure records.
dimensions -> (list)
Metadata attributes of the time series that are written in each measure record.
(structure)
Metadata attributes of the time series that are written in each measure record.
name -> (string)
The metadata dimension name. This is the name of the column in the Amazon Timestream database table record.
Dimensions cannot be named:
measure_name
,measure_value
, ortime
. These names are reserved. Dimension names cannot start withts_
ormeasure_value
and they cannot contain the colon (:
) character.value -> (string)
The value to write in this column of the database record.
timestamp -> (structure)
Specifies an application-defined value to replace the default value assigned to the Timestream record’s timestamp in the
time
column.You can use this property to specify the value and the precision of the Timestream record’s timestamp. You can specify a value from the message payload or a value computed by a substitution template.
If omitted, the topic rule action assigns the timestamp, in milliseconds, at the time it processed the rule.
value -> (string)
An expression that returns a long epoch time value.
unit -> (string)
The precision of the timestamp value that results from the expression described in
value
.Valid values:
SECONDS
|MILLISECONDS
|MICROSECONDS
|NANOSECONDS
. The default isMILLISECONDS
.http -> (structure)
Send data to an HTTPS endpoint.
url -> (string)
The endpoint URL. If substitution templates are used in the URL, you must also specify a
confirmationUrl
. If this is a new destination, a newTopicRuleDestination
is created if possible.confirmationUrl -> (string)
The URL to which AWS IoT sends a confirmation message. The value of the confirmation URL must be a prefix of the endpoint URL. If you do not specify a confirmation URL AWS IoT uses the endpoint URL as the confirmation URL. If you use substitution templates in the confirmationUrl, you must create and enable topic rule destinations that match each possible value of the substitution template before traffic is allowed to your endpoint URL.
headers -> (list)
The HTTP headers to send with the message data.
(structure)
The HTTP action header.
key -> (string)
The HTTP header key.
value -> (string)
The HTTP header value. Substitution templates are supported.
auth -> (structure)
The authentication method to use when sending data to an HTTPS endpoint.
sigv4 -> (structure)
Use Sig V4 authorization. For more information, see Signature Version 4 Signing Process .
signingRegion -> (string)
The signing region.
serviceName -> (string)
The service name to use while signing with Sig V4.
roleArn -> (string)
The ARN of the signing role.
kafka -> (structure)
Send messages to an Amazon Managed Streaming for Apache Kafka (Amazon MSK) or self-managed Apache Kafka cluster.
destinationArn -> (string)
The ARN of Kafka action’s VPC
TopicRuleDestination
.topic -> (string)
The Kafka topic for messages to be sent to the Kafka broker.
key -> (string)
The Kafka message key.
partition -> (string)
The Kafka message partition.
clientProperties -> (map)
Properties of the Apache Kafka producer client.
key -> (string)
value -> (string)
ruleDisabled -> (boolean)
Specifies whether the rule is disabled.
awsIotSqlVersion -> (string)
The version of the SQL rules engine to use when evaluating the rule.
errorAction -> (structure)
The action to take when an error occurs.
dynamoDB -> (structure)
Write to a DynamoDB table.
tableName -> (string)
The name of the DynamoDB table.
roleArn -> (string)
The ARN of the IAM role that grants access to the DynamoDB table.
operation -> (string)
The type of operation to be performed. This follows the substitution template, so it can be
${operation}
, but the substitution must result in one of the following:INSERT
,UPDATE
, orDELETE
.hashKeyField -> (string)
The hash key name.
hashKeyValue -> (string)
The hash key value.
hashKeyType -> (string)
The hash key type. Valid values are “STRING” or “NUMBER”
rangeKeyField -> (string)
The range key name.
rangeKeyValue -> (string)
The range key value.
rangeKeyType -> (string)
The range key type. Valid values are “STRING” or “NUMBER”
payloadField -> (string)
The action payload. This name can be customized.
dynamoDBv2 -> (structure)
Write to a DynamoDB table. This is a new version of the DynamoDB action. It allows you to write each attribute in an MQTT message payload into a separate DynamoDB column.
roleArn -> (string)
The ARN of the IAM role that grants access to the DynamoDB table.
putItem -> (structure)
Specifies the DynamoDB table to which the message data will be written. For example:
{ "dynamoDBv2": { "roleArn": "aws:iam:12341251:my-role" "putItem": { "tableName": "my-table" } } }
Each attribute in the message payload will be written to a separate column in the DynamoDB database.
tableName -> (string)
The table where the message data will be written.
lambda -> (structure)
Invoke a Lambda function.
functionArn -> (string)
The ARN of the Lambda function.
sns -> (structure)
Publish to an Amazon SNS topic.
targetArn -> (string)
The ARN of the SNS topic.
roleArn -> (string)
The ARN of the IAM role that grants access.
messageFormat -> (string)
(Optional) The message format of the message to publish. Accepted values are “JSON” and “RAW”. The default value of the attribute is “RAW”. SNS uses this setting to determine if the payload should be parsed and relevant platform-specific bits of the payload should be extracted. To read more about SNS message formats, see https://docs.aws.amazon.com/sns/latest/dg/json-formats.html refer to their official documentation.
sqs -> (structure)
Publish to an Amazon SQS queue.
roleArn -> (string)
The ARN of the IAM role that grants access.
queueUrl -> (string)
The URL of the Amazon SQS queue.
useBase64 -> (boolean)
Specifies whether to use Base64 encoding.
kinesis -> (structure)
Write data to an Amazon Kinesis stream.
roleArn -> (string)
The ARN of the IAM role that grants access to the Amazon Kinesis stream.
streamName -> (string)
The name of the Amazon Kinesis stream.
partitionKey -> (string)
The partition key.
republish -> (structure)
Publish to another MQTT topic.
roleArn -> (string)
The ARN of the IAM role that grants access.
topic -> (string)
The name of the MQTT topic.
qos -> (integer)
The Quality of Service (QoS) level to use when republishing messages. The default value is 0.
s3 -> (structure)
Write to an Amazon S3 bucket.
roleArn -> (string)
The ARN of the IAM role that grants access.
bucketName -> (string)
The Amazon S3 bucket.
key -> (string)
The object key. For more information, see Actions, resources, and condition keys for Amazon S3 .
cannedAcl -> (string)
The Amazon S3 canned ACL that controls access to the object identified by the object key. For more information, see S3 canned ACLs .
firehose -> (structure)
Write to an Amazon Kinesis Firehose stream.
roleArn -> (string)
The IAM role that grants access to the Amazon Kinesis Firehose stream.
deliveryStreamName -> (string)
The delivery stream name.
separator -> (string)
A character separator that will be used to separate records written to the Firehose stream. Valid values are: ‘n’ (newline), ‘t’ (tab), ‘rn’ (Windows newline), ‘,’ (comma).
batchMode -> (boolean)
Whether to deliver the Kinesis Data Firehose stream as a batch by using `
PutRecordBatch
https://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecordBatch.html`__ . The default value isfalse
.When
batchMode
istrue
and the rule’s SQL statement evaluates to an Array, each Array element forms one record in the `PutRecordBatch
https://docs.aws.amazon.com/firehose/latest/APIReference/API_PutRecordBatch.html`__ request. The resulting array can’t have more than 500 records.cloudwatchMetric -> (structure)
Capture a CloudWatch metric.
roleArn -> (string)
The IAM role that allows access to the CloudWatch metric.
metricNamespace -> (string)
The CloudWatch metric namespace name.
metricName -> (string)
The CloudWatch metric name.
metricValue -> (string)
The CloudWatch metric value.
metricUnit -> (string)
The metric unit supported by CloudWatch.
metricTimestamp -> (string)
An optional Unix timestamp .
cloudwatchAlarm -> (structure)
Change the state of a CloudWatch alarm.
roleArn -> (string)
The IAM role that allows access to the CloudWatch alarm.
alarmName -> (string)
The CloudWatch alarm name.
stateReason -> (string)
The reason for the alarm change.
stateValue -> (string)
The value of the alarm state. Acceptable values are: OK, ALARM, INSUFFICIENT_DATA.
cloudwatchLogs -> (structure)
Send data to CloudWatch Logs.
roleArn -> (string)
The IAM role that allows access to the CloudWatch log.
logGroupName -> (string)
The CloudWatch log group to which the action sends data.
elasticsearch -> (structure)
Write data to an Amazon Elasticsearch Service domain.
roleArn -> (string)
The IAM role ARN that has access to Elasticsearch.
endpoint -> (string)
The endpoint of your Elasticsearch domain.
index -> (string)
The Elasticsearch index where you want to store your data.
type -> (string)
The type of document you are storing.
id -> (string)
The unique identifier for the document you are storing.
salesforce -> (structure)
Send a message to a Salesforce IoT Cloud Input Stream.
token -> (string)
The token used to authenticate access to the Salesforce IoT Cloud Input Stream. The token is available from the Salesforce IoT Cloud platform after creation of the Input Stream.
url -> (string)
The URL exposed by the Salesforce IoT Cloud Input Stream. The URL is available from the Salesforce IoT Cloud platform after creation of the Input Stream.
iotAnalytics -> (structure)
Sends message data to an AWS IoT Analytics channel.
channelArn -> (string)
(deprecated) The ARN of the IoT Analytics channel to which message data will be sent.
channelName -> (string)
The name of the IoT Analytics channel to which message data will be sent.
batchMode -> (boolean)
Whether to process the action as a batch. The default value is
false
.When
batchMode
istrue
and the rule SQL statement evaluates to an Array, each Array element is delivered as a separate message when passed by `BatchPutMessage
https://docs.aws.amazon.com/iotanalytics/latest/APIReference/API_BatchPutMessage.html`__ to the AWS IoT Analytics channel. The resulting array can’t have more than 100 messages.roleArn -> (string)
The ARN of the role which has a policy that grants IoT Analytics permission to send message data via IoT Analytics (iotanalytics:BatchPutMessage).
iotEvents -> (structure)
Sends an input to an AWS IoT Events detector.
inputName -> (string)
The name of the AWS IoT Events input.
messageId -> (string)
The ID of the message. The default
messageId
is a new UUID value.When
batchMode
istrue
, you can’t specify amessageId
–a new UUID value will be assigned.Assign a value to this property to ensure that only one input (message) with a given
messageId
will be processed by an AWS IoT Events detector.batchMode -> (boolean)
Whether to process the event actions as a batch. The default value is
false
.When
batchMode
istrue
, you can’t specify amessageId
.When
batchMode
istrue
and the rule SQL statement evaluates to an Array, each Array element is treated as a separate message when it’s sent to AWS IoT Events by calling `BatchPutMessage
https://docs.aws.amazon.com/iotevents/latest/apireference/API_iotevents-data_BatchPutMessage.html`__ . The resulting array can’t have more than 10 messages.roleArn -> (string)
The ARN of the role that grants AWS IoT permission to send an input to an AWS IoT Events detector. (“Action”:”iotevents:BatchPutMessage”).
iotSiteWise -> (structure)
Sends data from the MQTT message that triggered the rule to AWS IoT SiteWise asset properties.
putAssetPropertyValueEntries -> (list)
A list of asset property value entries.
(structure)
An asset property value entry containing the following information.
entryId -> (string)
Optional. A unique identifier for this entry that you can define to better track which message caused an error in case of failure. Accepts substitution templates. Defaults to a new UUID.
assetId -> (string)
The ID of the AWS IoT SiteWise asset. You must specify either a
propertyAlias
or both analiasId
and apropertyId
. Accepts substitution templates.propertyId -> (string)
The ID of the asset’s property. You must specify either a
propertyAlias
or both analiasId
and apropertyId
. Accepts substitution templates.propertyAlias -> (string)
The name of the property alias associated with your asset property. You must specify either a
propertyAlias
or both analiasId
and apropertyId
. Accepts substitution templates.propertyValues -> (list)
A list of property values to insert that each contain timestamp, quality, and value (TQV) information.
(structure)
An asset property value entry containing the following information.
value -> (structure)
The value of the asset property.
stringValue -> (string)
Optional. The string value of the value entry. Accepts substitution templates.
integerValue -> (string)
Optional. A string that contains the integer value of the value entry. Accepts substitution templates.
doubleValue -> (string)
Optional. A string that contains the double value of the value entry. Accepts substitution templates.
booleanValue -> (string)
Optional. A string that contains the boolean value (
true
orfalse
) of the value entry. Accepts substitution templates.timestamp -> (structure)
The asset property value timestamp.
timeInSeconds -> (string)
A string that contains the time in seconds since epoch. Accepts substitution templates.
offsetInNanos -> (string)
Optional. A string that contains the nanosecond time offset. Accepts substitution templates.
quality -> (string)
Optional. A string that describes the quality of the value. Accepts substitution templates. Must be
GOOD
,BAD
, orUNCERTAIN
.roleArn -> (string)
The ARN of the role that grants AWS IoT permission to send an asset property value to AWS IoTSiteWise. (
"Action": "iotsitewise:BatchPutAssetPropertyValue"
). The trust policy can restrict access to specific asset hierarchy paths.stepFunctions -> (structure)
Starts execution of a Step Functions state machine.
executionNamePrefix -> (string)
(Optional) A name will be given to the state machine execution consisting of this prefix followed by a UUID. Step Functions automatically creates a unique name for each state machine execution if one is not provided.
stateMachineName -> (string)
The name of the Step Functions state machine whose execution will be started.
roleArn -> (string)
The ARN of the role that grants IoT permission to start execution of a state machine (“Action”:”states:StartExecution”).
timestream -> (structure)
The Timestream rule action writes attributes (measures) from an MQTT message into an Amazon Timestream table. For more information, see the Timestream topic rule action documentation.
roleArn -> (string)
The ARN of the role that grants permission to write to the Amazon Timestream database table.
databaseName -> (string)
The name of an Amazon Timestream database.
tableName -> (string)
The name of the database table into which to write the measure records.
dimensions -> (list)
Metadata attributes of the time series that are written in each measure record.
(structure)
Metadata attributes of the time series that are written in each measure record.
name -> (string)
The metadata dimension name. This is the name of the column in the Amazon Timestream database table record.
Dimensions cannot be named:
measure_name
,measure_value
, ortime
. These names are reserved. Dimension names cannot start withts_
ormeasure_value
and they cannot contain the colon (:
) character.value -> (string)
The value to write in this column of the database record.
timestamp -> (structure)
Specifies an application-defined value to replace the default value assigned to the Timestream record’s timestamp in the
time
column.You can use this property to specify the value and the precision of the Timestream record’s timestamp. You can specify a value from the message payload or a value computed by a substitution template.
If omitted, the topic rule action assigns the timestamp, in milliseconds, at the time it processed the rule.
value -> (string)
An expression that returns a long epoch time value.
unit -> (string)
The precision of the timestamp value that results from the expression described in
value
.Valid values:
SECONDS
|MILLISECONDS
|MICROSECONDS
|NANOSECONDS
. The default isMILLISECONDS
.http -> (structure)
Send data to an HTTPS endpoint.
url -> (string)
The endpoint URL. If substitution templates are used in the URL, you must also specify a
confirmationUrl
. If this is a new destination, a newTopicRuleDestination
is created if possible.confirmationUrl -> (string)
The URL to which AWS IoT sends a confirmation message. The value of the confirmation URL must be a prefix of the endpoint URL. If you do not specify a confirmation URL AWS IoT uses the endpoint URL as the confirmation URL. If you use substitution templates in the confirmationUrl, you must create and enable topic rule destinations that match each possible value of the substitution template before traffic is allowed to your endpoint URL.
headers -> (list)
The HTTP headers to send with the message data.
(structure)
The HTTP action header.
key -> (string)
The HTTP header key.
value -> (string)
The HTTP header value. Substitution templates are supported.
auth -> (structure)
The authentication method to use when sending data to an HTTPS endpoint.
sigv4 -> (structure)
Use Sig V4 authorization. For more information, see Signature Version 4 Signing Process .
signingRegion -> (string)
The signing region.
serviceName -> (string)
The service name to use while signing with Sig V4.
roleArn -> (string)
The ARN of the signing role.
kafka -> (structure)
Send messages to an Amazon Managed Streaming for Apache Kafka (Amazon MSK) or self-managed Apache Kafka cluster.
destinationArn -> (string)
The ARN of Kafka action’s VPC
TopicRuleDestination
.topic -> (string)
The Kafka topic for messages to be sent to the Kafka broker.
key -> (string)
The Kafka message key.
partition -> (string)
The Kafka message partition.
clientProperties -> (map)
Properties of the Apache Kafka producer client.
key -> (string)
value -> (string)
JSON Syntax:
{
"sql": "string",
"description": "string",
"actions": [
{
"dynamoDB": {
"tableName": "string",
"roleArn": "string",
"operation": "string",
"hashKeyField": "string",
"hashKeyValue": "string",
"hashKeyType": "STRING"|"NUMBER",
"rangeKeyField": "string",
"rangeKeyValue": "string",
"rangeKeyType": "STRING"|"NUMBER",
"payloadField": "string"
},
"dynamoDBv2": {
"roleArn": "string",
"putItem": {
"tableName": "string"
}
},
"lambda": {
"functionArn": "string"
},
"sns": {
"targetArn": "string",
"roleArn": "string",
"messageFormat": "RAW"|"JSON"
},
"sqs": {
"roleArn": "string",
"queueUrl": "string",
"useBase64": true|false
},
"kinesis": {
"roleArn": "string",
"streamName": "string",
"partitionKey": "string"
},
"republish": {
"roleArn": "string",
"topic": "string",
"qos": integer
},
"s3": {
"roleArn": "string",
"bucketName": "string",
"key": "string",
"cannedAcl": "private"|"public-read"|"public-read-write"|"aws-exec-read"|"authenticated-read"|"bucket-owner-read"|"bucket-owner-full-control"|"log-delivery-write"
},
"firehose": {
"roleArn": "string",
"deliveryStreamName": "string",
"separator": "string",
"batchMode": true|false
},
"cloudwatchMetric": {
"roleArn": "string",
"metricNamespace": "string",
"metricName": "string",
"metricValue": "string",
"metricUnit": "string",
"metricTimestamp": "string"
},
"cloudwatchAlarm": {
"roleArn": "string",
"alarmName": "string",
"stateReason": "string",
"stateValue": "string"
},
"cloudwatchLogs": {
"roleArn": "string",
"logGroupName": "string"
},
"elasticsearch": {
"roleArn": "string",
"endpoint": "string",
"index": "string",
"type": "string",
"id": "string"
},
"salesforce": {
"token": "string",
"url": "string"
},
"iotAnalytics": {
"channelArn": "string",
"channelName": "string",
"batchMode": true|false,
"roleArn": "string"
},
"iotEvents": {
"inputName": "string",
"messageId": "string",
"batchMode": true|false,
"roleArn": "string"
},
"iotSiteWise": {
"putAssetPropertyValueEntries": [
{
"entryId": "string",
"assetId": "string",
"propertyId": "string",
"propertyAlias": "string",
"propertyValues": [
{
"value": {
"stringValue": "string",
"integerValue": "string",
"doubleValue": "string",
"booleanValue": "string"
},
"timestamp": {
"timeInSeconds": "string",
"offsetInNanos": "string"
},
"quality": "string"
}
...
]
}
...
],
"roleArn": "string"
},
"stepFunctions": {
"executionNamePrefix": "string",
"stateMachineName": "string",
"roleArn": "string"
},
"timestream": {
"roleArn": "string",
"databaseName": "string",
"tableName": "string",
"dimensions": [
{
"name": "string",
"value": "string"
}
...
],
"timestamp": {
"value": "string",
"unit": "string"
}
},
"http": {
"url": "string",
"confirmationUrl": "string",
"headers": [
{
"key": "string",
"value": "string"
}
...
],
"auth": {
"sigv4": {
"signingRegion": "string",
"serviceName": "string",
"roleArn": "string"
}
}
},
"kafka": {
"destinationArn": "string",
"topic": "string",
"key": "string",
"partition": "string",
"clientProperties": {"string": "string"
...}
}
}
...
],
"ruleDisabled": true|false,
"awsIotSqlVersion": "string",
"errorAction": {
"dynamoDB": {
"tableName": "string",
"roleArn": "string",
"operation": "string",
"hashKeyField": "string",
"hashKeyValue": "string",
"hashKeyType": "STRING"|"NUMBER",
"rangeKeyField": "string",
"rangeKeyValue": "string",
"rangeKeyType": "STRING"|"NUMBER",
"payloadField": "string"
},
"dynamoDBv2": {
"roleArn": "string",
"putItem": {
"tableName": "string"
}
},
"lambda": {
"functionArn": "string"
},
"sns": {
"targetArn": "string",
"roleArn": "string",
"messageFormat": "RAW"|"JSON"
},
"sqs": {
"roleArn": "string",
"queueUrl": "string",
"useBase64": true|false
},
"kinesis": {
"roleArn": "string",
"streamName": "string",
"partitionKey": "string"
},
"republish": {
"roleArn": "string",
"topic": "string",
"qos": integer
},
"s3": {
"roleArn": "string",
"bucketName": "string",
"key": "string",
"cannedAcl": "private"|"public-read"|"public-read-write"|"aws-exec-read"|"authenticated-read"|"bucket-owner-read"|"bucket-owner-full-control"|"log-delivery-write"
},
"firehose": {
"roleArn": "string",
"deliveryStreamName": "string",
"separator": "string",
"batchMode": true|false
},
"cloudwatchMetric": {
"roleArn": "string",
"metricNamespace": "string",
"metricName": "string",
"metricValue": "string",
"metricUnit": "string",
"metricTimestamp": "string"
},
"cloudwatchAlarm": {
"roleArn": "string",
"alarmName": "string",
"stateReason": "string",
"stateValue": "string"
},
"cloudwatchLogs": {
"roleArn": "string",
"logGroupName": "string"
},
"elasticsearch": {
"roleArn": "string",
"endpoint": "string",
"index": "string",
"type": "string",
"id": "string"
},
"salesforce": {
"token": "string",
"url": "string"
},
"iotAnalytics": {
"channelArn": "string",
"channelName": "string",
"batchMode": true|false,
"roleArn": "string"
},
"iotEvents": {
"inputName": "string",
"messageId": "string",
"batchMode": true|false,
"roleArn": "string"
},
"iotSiteWise": {
"putAssetPropertyValueEntries": [
{
"entryId": "string",
"assetId": "string",
"propertyId": "string",
"propertyAlias": "string",
"propertyValues": [
{
"value": {
"stringValue": "string",
"integerValue": "string",
"doubleValue": "string",
"booleanValue": "string"
},
"timestamp": {
"timeInSeconds": "string",
"offsetInNanos": "string"
},
"quality": "string"
}
...
]
}
...
],
"roleArn": "string"
},
"stepFunctions": {
"executionNamePrefix": "string",
"stateMachineName": "string",
"roleArn": "string"
},
"timestream": {
"roleArn": "string",
"databaseName": "string",
"tableName": "string",
"dimensions": [
{
"name": "string",
"value": "string"
}
...
],
"timestamp": {
"value": "string",
"unit": "string"
}
},
"http": {
"url": "string",
"confirmationUrl": "string",
"headers": [
{
"key": "string",
"value": "string"
}
...
],
"auth": {
"sigv4": {
"signingRegion": "string",
"serviceName": "string",
"roleArn": "string"
}
}
},
"kafka": {
"destinationArn": "string",
"topic": "string",
"key": "string",
"partition": "string",
"clientProperties": {"string": "string"
...}
}
}
}
--tags
(string)
Metadata which can be used to manage the topic rule.
Note
For URI Request parameters use format: …key1=value1&key2=value2…
For the CLI command-line parameter use format: –tags “key1=value1&key2=value2…”
For the cli-input-json file use format: “tags”: “key1=value1&key2=value2…”
--cli-input-json
| --cli-input-yaml
(string)
Reads arguments from the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton
. If other arguments are provided on the command line, those values will override the JSON-provided values. It is not possible to pass arbitrary binary values using a JSON-provided value as the string will be taken literally. This may not be specified along with --cli-input-yaml
.
--generate-cli-skeleton
(string)
Prints a JSON skeleton to standard output without sending an API request. If provided with no value or the value input
, prints a sample input JSON that can be used as an argument for --cli-input-json
. Similarly, if provided yaml-input
it will print a sample input YAML that can be used with --cli-input-yaml
. If provided with the value output
, it validates the command inputs and returns a sample output JSON for that command.
See ‘aws help’ for descriptions of global parameters.
To create a rule that sends an Amazon SNS alert
The following create-topic-rule
example creates a rule that sends an Amazon SNS message when soil moisture level readings, as found in a device shadow, are low.
aws iot create-topic-rule \
--rule-name "LowMoistureRule" \
--topic-rule-payload file://plant-rule.json
The example requires the following JSON code to be saved to a file named plant-rule.json
:
{
"sql": "SELECT * FROM '$aws/things/MyRPi/shadow/update/accepted' WHERE state.reported.moisture = 'low'\n",
"description": "Sends an alert whenever soil moisture level readings are too low.",
"ruleDisabled": false,
"awsIotSqlVersion": "2016-03-23",
"actions": [{
"sns": {
"targetArn": "arn:aws:sns:us-west-2:123456789012:MyRPiLowMoistureTopic",
"roleArn": "arn:aws:iam::123456789012:role/service-role/MyRPiLowMoistureTopicRole",
"messageFormat": "RAW"
}
}]
}
This command produces no output.
For more information, see Creating an AWS IoT Rule in the AWS IoT Developers Guide.
None