1
votes

I have been able to use the AWS documentation to insert an mqtt message into a single column in a table. I would like to be able to update (not insert) multiple columns in the table. I used the DynamoDbv2 action in my IoT Rule, and I changed the IAM role to UpdateItem, but nothing is happening.

Is there a way to see where/when these errors are occuring? Should I create a Lambda function to handle this instead? Is there an example of this? Thanks.

2
How's it going? I'm facing a similar issue, I made two rules, one is used to insert A column and another is used to update B column. - troy

2 Answers

1
votes

First of all please keep in mind that DynamoDbV2 is using internally PutItem, so your are not able to only update attributes, but whole object will be overwritten.

If you want to update item you need to implement Lambda function and manually implement data update.

For IAM role, your trust relationship should contain: { "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "Service": "iot.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }

0
votes

You can use the DynamoDbV2 rule action to update multiple attributes (or columns if you will) in your DynamodDB table. Your role you provide to the Iot Rule needs to allow dynamodb:PutItem on the table in question. The role of course needs to have the IoT service in it's trust policy (also know as the assume role policy document in some places).

To help troubleshoot any issues you have turn on IoT logging and set the level to Debug. Then you can view any errors in the AWS Cloudwatch Logs.

https://docs.aws.amazon.com/iot/latest/developerguide/iot-rule-actions.html