0
votes

I'm newbie in AWS IoT and now try to play around with existing resources to understand the main concept. I faced with an odd behaviour while using aws iot-data command trying to publish data into one of AWS reserved topics. Let's say I want to update named Shadow called stubShadow of some stub thing (I'm using Test tab in the AWS IoT Dashboard):

 aws iot-data update-thing-shadow --thing-name stub --shadow-name stubShadow \
    --cli-binary-format raw-in-base64-out \
    --payload '{"state":{"desired":{"ColorRGB":[0,11,11]}},"clientToken":"21b21b21-bfd2-4279-8c65-e2f697ff4fab"}' /dev/stdout

and it works pretty well, I can observe $aws/things/stub/shadow/name/stubShadow/update/accepted topic for updates.

Now I want to publish a message using topic argument. Here is an example:

aws iot-data publish --topic "$aws/things/stub/shadow/name/stubShadow/update" \
    --cli-binary-format raw-in-base64-out \
    --payload '{"state":{"reported":{"ColorRGB":[0,11,11]}},"clientToken":"21b21b21-bfd2-4279-8c65-e2f697ff4fab"}'

and nothing happens... I wonder what's wrong with this command with sending direct message to a AWS Service topic? Am I miss something? Because for regular (manually created) topics it works well.

1

1 Answers

0
votes

As the document says,

payload is the base64 encoded representation of stringify json message

{"state":{"reported":{"ColorRGB":[0,11,11]}}}

console.log(btoa(JSON.stringify({"state":{"reported":{"ColorRGB":[0,11,11]}}})))

payload : eyJzdGF0ZSI6eyJyZXBvcnRlZCI6eyJDb2xvclJHQiI6WzAsMTEsMTFdfX19

aws iot-data publish --topic "$aws/things/stub/shadow/name/stubShadow/update" --payload 'eyJzdGF0ZSI6eyJyZXBvcnRlZCI6eyJDb2xvclJHQiI6WzAsMTEsMTFdfX19'