IoT or the Internet of Things is new craze. This technology is touted to be future. Internet of Things is basically a network of interconnected electronic devices, physical objects, etc. (referred as “things”) and identified with a Unique Identifier through which they transfer data and interact with each other. Let us look in detail how to build an IoT application in Rails.
AWS IoT provides secure, bi-directional communication between Internet-connected things (such as sensors, actuators, embedded devices, or smart appliances) and the AWS cloud.
AWS IoT consists of the following components:
Thing Shadows service.
Security and Identity service
To learn about how the above components work see AWS interactive tutorial for IoT in this link: https://console.aws.amazon.com/iot/home?region=us-east-1#/tutorial/help?step=1
Setup for using AWS IoT:
As the steps are already defined in AWS website here we try to give the glimpse of the steps:
Creating a thing:
First step is to create a thing with the optional device attributes to uniquely identify the connected devices. To create a thing click “Create a Resource” button in the Resources dashboard page of AWS IoT and choose ‘Create a thing’.
Creating a certificate and activating it:
After creating a thing we need to create a certificate which will be used to authenticate the communication to the AWS IoT. To create a certificate click “Create a Resource” button in the Resources dashboard page of AWS IoT and choose ‘Create a certificate’ and then we can generate 1-click certificate are upload our own. After creating, download the certificate, private and public key as public and private key cannot be downloaded after closing the create panel.
Generate Root CA file:
Copy the text generated in this link: https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem and save it as a file with extension(.pem) ex: ‘RootCA.pem’.
After creating the certificate select it and choose ‘Activate’ from the “Actions” to activate the certificate.
Creating a policy and attaching it to certificate:
After creating the certificate we need a policy to authorize the communications to a thing. To create a certificate click “Create a Resource” button in the Resources dashboard page of AWS IoT and choose ‘Create a policy’ and input the name and the statement by specifying the actions (iot:publish, iot:subscribe, etc. ) and the resources (specify * to authorize for all resources or input the specific ARN) and then click ‘Add Statement’ and then click ‘Create’.
After creating the policy click on the certificate that we created in the last step and from the ‘Actions’ menu select ‘Attach a policy’ and type policy name to attach.
For more details in setting up AWS IoT see: https://docs.aws.amazon.com/iot/latest/developerguide/iot-gs.html
In the upcoming post we will see in detail about the creating an IoT application with the help of MQTT.