The DynamoDB (dynamoDB
) action writes all or part of an MQTT message to an Amazon DynamoDB table.
You can follow a tutorial that shows you how to create and test a rule with a DynamoDB action. For more information, see Tutorial: Storing device data in a DynamoDB table.
NoteThis rule writes non-JSON data to DynamoDB as binary data. The DynamoDB console displays the data as base64-encoded text.
RequirementsThis rule action has the following requirements:
An IAM role that AWS IoT can assume to perform the dynamodb:PutItem
operation. For more information, see Granting an AWS IoT rule the access it requires.
In the AWS IoT console, you can choose or create a role to allow AWS IoT to perform this rule action.
If you use a customer managed AWS KMS key (KMS key) to encrypt data at rest in DynamoDB, the service must have permission to use the KMS key on the caller's behalf. For more information, see Customer Managed KMS key in the Amazon DynamoDB Getting Started Guide.
When you create an AWS IoT rule with this action, you must specify the following information:
tableName
The name of the DynamoDB table.
Supports substitution templates: API and AWS CLI only
hashKeyField
The name of the hash key (also called the partition key).
Supports substitution templates: API and AWS CLI only
hashKeyType
(Optional) The data type of the hash key (also called the partition key). Valid values: STRING
, NUMBER
.
Supports substitution templates: API and AWS CLI only
hashKeyValue
The value of the hash key. Consider using a substitution template such as ${topic()}
or ${timestamp()}
.
Supports substitution templates: Yes
rangeKeyField
(Optional) The name of the range key (also called the sort key).
Supports substitution templates: API and AWS CLI only
rangeKeyType
(Optional) The data type of the range key (also called the sort key). Valid values: STRING
, NUMBER
.
Supports substitution templates: API and AWS CLI only
rangeKeyValue
(Optional) The value of the range key. Consider using a substitution template such as ${topic()}
or ${timestamp()}
.
Supports substitution templates: Yes
payloadField
(Optional) The name of the column where the payload is written. If you omit this value, the payload is written to the column named payload
.
Supports substitution templates: Yes
operation
(Optional) The type of operation to be performed. Valid values: INSERT
, UPDATE
, DELETE
.
Supports substitution templates: Yes
roleARN
The IAM role that allows access to the DynamoDB table. For more information, see Requirements.
Supports substitution templates: No
The data written to the DynamoDB table is the result from the SQL statement of the rule.
ExamplesThe following JSON example defines a DynamoDB action in an AWS IoT rule.
{
"topicRulePayload": {
"sql": "SELECT * AS message FROM 'some/topic'",
"ruleDisabled": false,
"awsIotSqlVersion": "2016-03-23",
"actions": [
{
"dynamoDB": {
"tableName": "my_ddb_table",
"hashKeyField": "key",
"hashKeyValue": "${topic()}",
"rangeKeyField": "timestamp",
"rangeKeyValue": "${timestamp()}",
"roleArn": "arn:aws:iam::123456789012:role/aws_iot_dynamoDB"
}
}
]
}
}
See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4