Do you want to build an IoT app without compromising security?
Sit back and get comfortable, as I show you the services you need
to build an IoT app that's ready to scale.
Today's episode comes from Javier from Costa Rica.
When Javier isn't deep into all things tech, he's snowboarding,
or at least dreaming of it since there isn't any snow in Costa Rica.
Let's hear from Javier.
Hello, I'm Javier, and I'm trying to make an application of a shopping list app
that helps people with the process of shopping in person
from the moment they started their list at home to the moment they're in the store making the purchase.
It will have various functionalities, like a catalog of products, size,
user shopping lists, costs and budgets, and many more functionalities
that will simplify the whole process for the user.
The app includes several features that will improve a lot of the customer's experience inside the store
with beacons, Bluetooth and Wi-Fi nodes.
The three main functionalities that we are looking with this technology are:
first, proximity and contextual marketing where we can send push notifications to users.
Second, indoor guidance where we can guide the user to get their products rapidly. inside the store.
And third, analytics where we can know everything the user did inside the store when they were there.
Javier wants these IoT devices to help grocery shoppers find the items they need while inside a store.
I'll also show you where you can purchase hardware
that's designed for IoT applications and optimized for communication with the cloud.
Every IoT app needs the right hardware.
I suggest checking out the AWS Partner Device Catalog
to find hardware that's designed for the cloud and has the features that you need.
Javier will search for Bluetooth Low Energy Beacons.
The device catalog has a search bar and filters that you can select.
Make sure you select FreeRTOS in the filter.
FreeRTOS is a real-time operating system for microcontrollers.
Amazon has built an extension to FreeRTOS,
which includes support for AWS Services including AWS IoT Core.
IoT Core lets you connect IoT devices to the cloud without needing to deal with servers.
A key ingredient to building useful IoT apps
is their ability to ingest data from the environment and respond to that data.
This might require some information from the user through a web or mobile app
in order to determine which metrics to look for in the actual environment.
Let's look at an example of this pattern in Javier's grocery app.
I'm assuming most people prepare their shopping lists when they are at home,
before they leave for the store.
The optimal route to navigate the grocery store based on the customer's shopping list
will appear as soon as the customer selects the grocery store
and saves their shopping list for that store.
The app will hit Amazon API Gateway,
which will forward the request to a DynamoDB endpoint to save the shopping list to a table.
API Gateway makes it easy to develop and secure APIs for scale.
DynamoDB is a fast and flexible no-SQL database.
Every app needs secure user authentication and authorization.
Amazon Cognito lets you add user signup, sign in, and access control
to your web and mobile apps quickly and easily.
With Cognito, users can sign in using their existing Amazon, Facebook, Google or Apple credentials.
You can use an Amazon Cognito user pool to control who can access your API in Amazon API Gateway.
You'll use a feature of DynamoDB called DynamoDB Streams
which captures information about every modification to data in the table.
DynamoDB can be integrated with AWS Lambda,
so you can create triggers, which are pieces of code
that automatically respond to events in DynamoDB Streams.
For Javier's app, when the shopping list is updated,
a Lambda function will read data from the stream,
calculate the optimal route to shop for items in the grocery store,
and return the response to the frontend.
Lambda allows you to run code without managing servers.
For Javier's use case, he'll set up beacons at points along the grocery aisle,
each beacon will store its X and Y coordinates in the store
and the items in the same radius of that beacon.
Now you can imagine that having to parse all of your devices' data that's coming in,
figuring out which data points are meaningful, and how to respond to them
can be painful if you don't have a good process in place.
This is where IoT Rules for MQTT Topics can help.
MQTT Topics identify IoT messages.
Rules for AWS IoT allow you to filter through the data coming in from the device.
IoT rule actions allow you to take action from the data in the message broker.
You're going to use these features a lot
as a way for your devices to respond to the environment in real-time.
In Javier's app, he will have a Topic that's for the items in the aisle.
The payload of this topic will contain a Boolean variable
to indicate if new items have been added to the aisle.
If this variable is set to true, then the IoT rule action will update the grocery store items in the database.
I've left a link at the bottom of the video on how to choose a database for your use case.
No-SQL databases are a solid choice for IoT data,
so I'm going to recommend DynamoDB to receive the data from Javier's devices.
Another feature you might be thinking about building for your app
is sending your customer a notification based on the data coming from the IoT device.
This is another use case where an IoT rule can trigger an IoT rule action
that sends a message over SNS.
Let's look at Javier's app as an example.
As a customer navigates the grocery store, the position of their phone
and the next item to pick up in the shopping list will be sent to the IoT devices in the grocery store.
The device will compare the GPS position of the phone
to the radius where that item is located in the store.
If the customer passes the area where the item on the shopping list is located
without checking the item off,
then the IoT rule action will trigger Amazon Simple Notification Service.
Simple Notification Service is a fully managed messaging service
that you can use to send messages directly to your users.
Now, before you run off to build your IoT app,
make sure you do these two things.
In IoT Core, make sure you use the IoT Device Registry.
This feature allows you to store information about all of your devices in JSON.
So in Javier's use case, the Device Registry would contain metadata
like the grocery store ID, the X & Y location of the beacon in the grocery store,
and the foods that can be found in that aisle.
It's technically optional, but it'll make your life a lot easier
trying to find out if one of your devices needs to be fixed.
You'll thank me later.
The second is secure your devices.
I know it's tempting to say I don't have time for security,
I need to get my app out.
That my friend, is a mistake.
The good thing is there are security mechanisms built into IoT Core
You'll use X.509 certificates to provide IoT core with the ability
to authenticate and device connections.
Make sure you create one unique certificate per device.
You can generate certificates in the AWS console, CLI or programmatically.
I know, I covered a lot.
I'll recap what I went over
Purchase hardware that's designed for the cloud in the AWS Partner Device Catalog.
Use AWS IoT Core to build your IoT app.
Create an IoT rule action to trigger an Amazon SNS push notification to your customers.
Need an API that connects to a No-SQL database?
Use Amazon API Gateway with Amazon Dynamo DB.
Use AWS Lambda to react to changes in DynamoDB in real time.
With an IoT app like this, you'll be bringing home the bacon in no time.
It doesn't matter when you start as long as you just get started.
Don't forget to check out the links that I've left for you below this video.
Thanks for hanging out with me, see you soon.