IoT Events: Publish IoT Topic action with dynamic topic name

0

I'd like to be able to publish a message to a topic, which name is build up dynamically based on one of the input values. I can access to the input already when setting up Transition Events, but can't find a way to interpolate the input value into the topic name.

Suppose I have an input such as: $input.foo = bar Would like to use it in the topic name as: "my/topic/$input.foo", resulting into "my/topic/bar"

Have tried all type of proposed substitution templates w/o success (https://docs.aws.amazon.com/iotevents/latest/developerguide/iotevents-expressions.html)

profile pictureAWS
feita há 2 anos464 visualizações
1 Resposta
0

Answering to my own question, after some further testing. I did not manage to interpolate the topic dynamically on-the-fly as I wanted. Instead, I found a workaround by declaring a variable that contains the resolved interpolation in a previous state. For instance, the variable leds_topic is initialized with 'gate/' + $input.gate_sensors.gateid + '/leds' Aterwards, I can publish to that topic using as Topic name ($variable.leds_topic)

profile pictureAWS
respondido há 2 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas