Tuesday 6 June 2017

Rule Query Statements for AWS Iot Topic Publishes

I am looking to create a rule for our Amazon IOT account that executes a lambda function any time a device connects and publishes to a specified topic. However, contrary to the normal execution pathway of such rules, I am not looking to use the rules query engine to select values from the message published to that topic.

For example, we have created a lambda function for just-in-time device registration similar to what is posted here : https://aws.amazon.com/blogs/iot/just-in-time-registration-of-device-certificates-on-aws-iot/ that uses the topic filter '$aws/events/certificates/registered/'....

So our rule uses 'Select * from '$aws/events/certificates/registered/' to execute lambda. Inside the lambda, the NodeJS function has a 'certificateID' property.

I am looking for a topic filter that covers whenever a thing publishes to a particular topic. So I want to subscribe to something like '$aws/events/topics/published/' that will give me the principal metadata when passed to a NodeJS lambda function, as well as the message contents. And, what would the event object in the NodeJS lambda look like?

Additionally, if anyone can point me to an event tree more descriptive than the one here: http://docs.aws.amazon.com/iot/latest/developerguide/topics.html I would be appreciative.



via Kevin Hirst

No comments:

Post a Comment