You are on page 1of 4

AWS IoT Vending Machine

You can use the AWS IoT to communicate with Vending Machines through wifi
module with IAM credentials.

Background Information
In order to ensure the secured communication between IoT devices and AWS IoT
Core, Devices may use X.509 certificates to connect to AWS IoT using TLS mutual
authentication protocols. AWS Cloud security mechanisms protect data as it moves
between AWS IoT and other devices or AWS services.

This mutual TLS authentication mode requires that a device certificate meets either
of the following two conditions:

1. The certificate used on the IoT device is issued by AWS IoT Core
2. The CA certificate which is used to sign IoT device certificate is pre-imported
into a customer’s AWS account and associated with their AWS IoT Core
environment.
Implementation Methodology
The entire implementation can be divided into three modules: Client Endpoint, AWS
IoT Core and Vending Machine.

 Client Endpoint:
 Taking the drugs data to process.
 Uses database, like MySQL, to store information such as the device ID,
location, drug request information and drug dispense information.
 IoT Core:
 Response to create things, Polices, and certificates.
 Response of communicating with Vending Machine through mqtt protocol to
publish and subscribe the data.

Creating Virtual server in AWS:


 First we have to create AWS account.
 Go services and select EC2, click on Launch Instance
> select Free tier only
> Select Ubuntu Server 16.04 LTS (HVM), SSD Volume Type.
> Click Review and Launch.
> Download key pair and save for further communication.
 Using Putty or SSH we do connect with virtual server

Pushing Project code to server:


 Push code from local machine to server using winscp.
 Or else clone code from git to server.
 Install all the software’s in server virtual instance from requirements.txt file.

Configuring the IAM credentials:


 We need to create IAM account as per AWSIOT configuration Document.
 After connecting to the server in command prompt type aws configure.
 Provide the information like
 Aws Access Key ID : your Key Id form IAM credential file
 Aws Secret Aceess Key : Secret Aceess Key form IAM credential file
 Default region name : Your AWS account region
 Default output format : json

Adding Vending Machine through python Script:


 For Adding Vending Machine in AWS IoT environment, We are using AwsHelper
Module present in Aws package in our e_health Project.

 def registerNewVm(self, thingId, location):


try:
self.awsClient.create_thing(
thingName=thingId,
thingTypeName='VendingMachines',
attributePayload={
'attributes': {
'id': thingId,
'location': location
}
}
)
print('Thing created')
 Run below command in command prompt of QA server or Production Server to
add Vending Machine in IOT.ubuntu@.....:~/e_health$python
Aws/AwsHelpey.py ‘Vending_Machine_Id’ ‘Location’

You might also like