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
posta 2 anni fa464 visualizzazioni
1 Risposta
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
con risposta 2 anni fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande