Reputation: 1789
I've got a lambda function called by an IoT rule and I would like to know the topic name from inside this lambda function.
So far i'm only able to retrieve the message data from the event
parameter. Nothing in the context
parameter neither.
I haven't found anything in the documentation...
Is it even possible ?
Upvotes: 3
Views: 1054
Reputation: 841
You need to use topic() function in AWS IoT SQL query. Like this:
SELECT * as data, topic() as topic FROM 'desired/+/topic'
In this case, your event will include the original message in 'data' field and the used topic in 'topic' field. You can also use integer number as a parameter inside topic() function, to return only sub-group.
More data in oficial documentation: http://docs.aws.amazon.com/iot/latest/developerguide/iot-sql-functions.html#iot-function-topic
Upvotes: 8