'AWS IoT - SQL Question - Create JSON from '*'

I am trying to find out whether it's possible to create JSON (to forward to a Kinesis stream) based on a combination of a non-JSON input string and some IoT functions

More specifically, something like

SELECT topic() as topic, clientid() as device, * as msg FROM 'sometopic'

Where the message could be anything (in my case a CSV payload/string)

While the rule as such does not trigger any error when entering and updating, it does not seem to forward anything to the Kinesis stream. I also cannot find any trace in any cloudwatch log I looked.

A slightly adapted rule

SELECT topic() as topic, clientid() as device,* FROM 'sometopic'

works fine when the device sends a JSON string (e.g. {"msg":"message payload"})

Ideally it would be more optimal if the client could just publish "message payload"

(Using basic ingest)

All tips warmly welcomed!

Tx

Peter



Solution 1:[1]

Some rule actions don't support non-JSON payloads. To send binary data to a rule action that only supports JSON, you can encode the data in base64 and then decode it in the receiving service.

SELECT topic() as topic, clientid() as device, encode(*, 'base64') as msg FROM 'sometopic'

See Working with binary payloads.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Mayank Pathela