My manager gave me an AWS IoT Button
With the touch of a button you can notify the world that you touched a button.
I was sitting at my desk the other day, busily shifting paradigms and engaging synergies, when my manager plopped a small brown paper box on my desk.
“What’s this?” I asked, setting aside my efforts to break down silos through gamified product-thinking.
“It’s an AWS IoT Button. From Amazon. Do something cool and write about it,” he replied.
AWS IoT Button?
Wow, that’s complicated.
So I turned my attention to the button. And the documentation was pretty understandable. Within an hour I had hooked the button into the team’s Slack channel, thanks largely to a pre-existing AWS Lambda blueprint for Slack integration.
This is all kinds of fantastic for me. With the touch of a button I can execute more code than all the Apollo missions combined and annoy my team by spamming the Slack channel?
But what exactly does the button do? Like, under the hood?
Good question, Mike
Under the hood we’re taking advantage of a slew of AWS IoT features:
- The Thing — in this case, the button itself. IoT maintains a Registry of all your Things, which can be given a Thing Type and a couple of searchable attributes. You link Things with Certificates.
- Certificates — these are generated to enable mutual authentication between the Thing and AWS. Certificates also link Things to Policies.
- Policies — these are JSON documents that grant your Things specific access to specific resources on behalf of specific users. I think. The Button uses a Policy to tie a Thing to a Topic.
- Topics — imagine a fancy publish/subscriber queue. Things generate data, and when they do the data will usually end up being pushed to one of these Topics to be consumed by a Rule.
- Rules — here’s where things get interesting. These Rules are simple business rules, as in a rules engine. On a truthful evaluation of a business rule (given the input from your Thing) the data can be dispersed to any one of AWS’s many Services via an Action.
- Actions — one of AWS’s many services. Such as Lambda, which is what I used to trigger the Slack integration.
Okay, that’s a lot of background, so let’s go through the Button example.
I press the Button, which initiates Internal Button Logic. This logic connects (via Certificate) to the AWS IoT endpoint assigned to the Button (which is a Thing in the Registry). When the connection is established and authenticated the Button uploads its state data (what kind of click, how much battery power is left, and its identifier) to the IoT endpoint.
So far so good.
When the IoT endpoint receives the data it publishes it to the associated Topic (which is known via the Thing’s Certificate’s Policy). A Rule is watching this Topic and, when it notices the incoming data, evaluates it against the Rule’s conditional (for the button the conditional is “is there data?” since data is only uploaded on a click event). Assuming truthful evaluation, the data is then shipped off to the associated Action. Which in this case is an AWS Lambda. A Lambda that annoys my team.
As for me, I’ll have to wait for my manager to interrupt me again with a new toy. I don’t have time to invest in this IoT stuff while there are all these glass ceilings to leverage via B2B mindshare.