In this video you will learn how to create a resource or what's called the thing that is a logical representation of a physical device using Amazon Web Service IoT device metadata, shadow state. Lynn Langit demonstrates how to create a thing and how to set attributes for successfully sending messages to your device.
- [Voiceover] All right, in the previous movie, we looked at the MQTT protocol and logical representations of client connections as client IDs, and topics, which are destinations for the messages to be sent or retrieved from. So you publish to a topic, or you subscribe to a topic to send or receive. Now in the Amazon IoT console, we have a couple different things to take a look at, so let's start with creating a resource. And we're going to create what's called a thing. A thing is a logical representation of a physical device.
So I'm gonna call it mydeviceABC. Now when you create a thing, you're gonna associate this via a bootstrapping process with an actual physical device, and you will uniquely identify it. There's a couple steps in this process, so the first step is to create the thing. Now things can have attributes. Typical attributes are ID, model number, location, and really whatever you want. So a tip that I have is to develop a syntax for attributes.
Attributes are associated with a logical device, which will be then associated with a physical device. So if you click on the device, you can see that we have the name for the device, we have what's called a REST API endpoint. Now this is the actual device of your Amazon gateway or broker. So this is where the messages are being sent, from your physical device, which is associated to the logical device, and it's being sent to this endpoint.
There's one endpoint per Amazon account. So another tip from the real world, when you are going in a production situation, you normally will have multiple Amazon accounts, because you will have a development endpoint, developing your code, and then you will have usually a staging and a production endpoint. So here is an example of a topic. Now this topic is sort of interesting. We saw the backslash or forward slash syntax in the previous movie, but we have a dollar sign here. Dollar sign means reserved. So there is a special topic associated with each device called a shadow.
So in addition to the attributes, which are shown here, which represent static metadata about the device, although you can edit them, but they're generally static, you have data associated with the device that changes over time. So for example, if this was a thermostat, you might have current temperature. You might have current location, if it's installed in a particular homeowner's location. So the idea with this is that we have a built-in capacity to store the state of an aspect of the device on the Amazon ecosystem if the device is disconnected.
Which again reflects the reality of IoT. You're going to have devices that lose connectivity, so you have really two ways to store information about devices. You have sort of permanent information under the attributes, and then you have changeable information under the shadows. So if we wanted to work with this, we would click Edit. And here we could work with any of the attributes. And if we wanted to work with the shadow, we would click on Update Shadow. So the shadow state has a desired, and it has a reported state.
And then it does a dif between these two states. And then you can update the shadow, generally when the device reconnects. Now notice this blue button down at the bottom, Connect a device. If I click on this, it's gonna take me to the SDK page, because as I said, there's another step in this process, which is to actually write a bootstrapper that you then load onto your device. So again, let's take something from the real world, a thermostat, and then you have to run that code on the device, which will then associate the logical representation in the Amazon ecosystem with the physical device.
Now I've been doing production work in Node. You can see here if I click on Node, it tells exactly what I need to do. I need to create and download security credentials for the device, but I'm getting a little bit ahead of myself. I wanted to show you kind of the process, which is going back to the Resources, the first step is you create a device, and you associate metadata with it. You generally don't start with the shadow state until you put the device into production.
Starting with top-level categories of storage, data, computer, and services, Lynn guides you through planning your ideal AWS architecture, providing service demos using the AWS Console, command-line interface, and other tools. Learn when to use which service for which business case, such as Docker or Lambda or DynamoDB or Aurora? She shows how to script creation of services such as S3 buckets and EC2 instances, create and populate a managed data warehouse, and develop a data processing pipeline that works for you. Chapter 6 covers the AWS Internet of Things (IoT) services.
These exercises can help you build proof-of-concepts, minimum viable products, and deployable solutions to scale and support big data initiatives at your company.
- Setting up your AWS account
- Using AWS tools
- Defining your minimum viable products
- Choosing computer, storage, and data services
- Using S3, EC2, or Docker for website hosting
- Developing an AWS website
- Using a data warehouse
- Developing a data processing pipeline
- Developing an Internet of Things project with AWS