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
질문됨 2년 전464회 조회
1개 답변
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
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠