3
votes

I subscribe Aws Iot topic;

12345678/state

I try to write a rule to get this topic's payload at

12345678/shadow/update

I have written my rule by following these steps;

  1. My query string is

SELECT * FROM '+/state'

  1. My action is republishing everything without changing to other topic like this below

$$aws/things/${topic(1)}/shadow/update

When i write some static data instead of topic(1) function like "test", it works. However, i couldn't get topic name dynamically. There is no suitable document explaining how can achieve getting this topic name.

What is the right way to get topic name which is in my case "12345678"?

2
Can you explain what ${topic(1)} means? I'm trying to send an SNS every time a thing is updated. I've got it working, but the SNS payload doesn't specify which thing was updated.falsePockets

2 Answers

5
votes

Actually, there was no problem getting topic name by using topic(1) function like this below;

$$aws/things/${topic(1)}/shadow/update

The problem was about policy permission. After adding necessary publish permissions to my policy. I start getting payloads.

0
votes

For anyone else who can't figure out why

${topic(1)}

works for Arda, here is why:

https://docs.aws.amazon.com/iot/latest/developerguide/iot-substitution-templates.html

Turns out you can do "substitution templates" in the republish topic string.

Your next issue will be making sure the role assigned to the rule has a policy attached to it that allows it to publish to the iot core topic (doesn't get a policy that permits this automatically for some reason).