The first step is to register a new device to our IoT Core platform. Follow these steps:
- From the IoT console at https://console.aws.amazon.com/iot/, we can click on Manage, then Things, and register a new device by clicking on the Register a thing button as shown in the following screenshot:
- Click on the Create a single thing button or import a list of things from S3.
- We then have to define our device name, my-iiot-book-device; a simpletest type; and a group with the name my-iiot-book-group. To create a type and a group, click on the Create a type button and the Create group button. Finally, click on the Next button:
Why do we need to add a group and type? Normally, when we have thousands of devices installed, we need an easy way to look for them. If we need more information, we can add attributes to devices and groups.
- We then have to create a X.509 certificate for our device. We can simply click on the Create certificate button to do this.
- The last step is to activate the certificate by clicking on the Activate button and to download all the certificates created:
- We can save our certificates in an empty folder called iiot-book-aws, then rename the certificate's prefix with a new prefix, my-iiot-book-device. For example, this might look as follows—my-iiot-book-device.public.key.
- In the same folder, download the certificate authority from https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem and rename it root-CA.pem.
Do not download the proposed CA by AWS on the following screen, because at the time of writing this book, AWS IoT has a bug.
- To conclude our registration, we have to click on the Attach a policy button to attach the previously created policy:
- From the drop-down menu, we have to select our policy and register our thing as shown in the following screenshot:
The device should be now ready, as shown in the following screenshot:
We can add more devices by clicking on the Create button, or we can manage the certificates from the Secure menu. Alternatively, we can define more groups and more devices from the Manage menu. Finally, we can also subscribe or test the MQTT topic using the Test menu.