IoT SQL function `get_dynamodb` fails unexpectedly

0

Execution of the get_dynamodb function of IoT SQL fails with a strange error message when calling it with the four parameters specified in the documentation https://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-functions.html.

My rule definition equals

SELECT
    *,
    get_dynamodb("myTableName", "devEui", WirelessMetadata.LoRaWAN.DevEui, "myRoleArn") AS context
FROM 'myTopic'
WHERE
    message.WirelessMetadata.LoRaWAN.FPort = 10
    OR message.WirelessMetadata.LoRaWAN.FPort = 32

I have configured fine-grained logging for AWS IoT Core and see the following error message in CloudWatch

{
logLevel: ERROR
reason: ExternFunctionException
status: Failure
timestamp: 2021-12-29 07:12:10.436
details: Function 'GetDynamodb' failed to execute for rule 'XXX'. get_dynamodb takes either 4 or 6 arguments, but 4 given. Expected get_dynamodb(tableName, partitionKeyName, partitionKeyValue, roleArn) or get_dynamodb(tableName, partitionKeyName, partitionKeyValue, sortKeyName, sortKeyValue, roleArn).
eventType: RuleExecution
}

Is there something I'm missing or is the IoT Core SQL function documentation outdated?

asked 2 years ago385 views
1 Answer
0
Accepted Answer

I solved this by fixing a typo in the query. Namely, the partitionKeyValue argument missed the message prefix. The error message was a bit misleading as it stated that I had called the function with four arguments even though one of these was undefined.

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions