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
preguntada hace 2 años464 visualizaciones
1 Respuesta
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 hace 2 años

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas