Get started with your Intel Edison by updating to the latest firmware and setting up a serial terminal. You can find the instructions here:
Get started with Intel Edison technology
Before you continue, we recommend that you read the AWS IoT Quickstart. If you are already familiar with AWS IoT, continue to the next step.
The AWS CLI is used to interoperate with Amazon Web Services. To view the help documentation, you must install Groff and a different version of less.
We assume you have internet access from the device to download and install these packages.
Setup the Edison repo by replacing anything you have in the /etc/opkg/base-feeds.conf file with the following
src/gz all http://repo.opkg.net/edison/repo/all
src/gz edison http://repo.opkg.net/edison/repo/edison
src/gz core2-32 http://repo.opkg.net/edison/repo/core2-32
Setup the IoT repo and apply the new configurations.
echo "src intel-iotdk http://iotdk.intel.com/repos/3.0/intelgalactic/opkg/i586" > /etc/opkg/intel-iotdk.conf
opkg update
Install pip with setuptools.
wget https://bootstrap.pypa.io/get-pip.py --no-check-certificate
python get-pip.py
wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py
python ez_setup.py --insecure
Install the AWS CLI by issuing the following command:
$ pip install awscli
To view help files using the aws iot help
command, the Groff and a
non-BusyBox version of less packages are required.
Execute the following commands to install Groff:
$ wget http://ftp.gnu.org/gnu/groff/groff-1.22.3.tar.gz
$ tar -zxvf groff-1.22.3.tar.gz
$ cd groff-1.22.3
$ ./configure
$ make
$ make install
$ export PATH=$PATH:/usr/local/bin/
$ cd ~
First, rename the old version of less:
$ mv /usr/bin/less /usr/bin/less-OLD
Next, install the new version of less:
$ wget http://www.greenwoodsoftware.com/less/less-458.zip
$ unzip less-458.zip
$ cd less-458
$ chmod 777 *
$ ./configure
$ make
$ make install
$ cd ~
To make sure everything is installed correctly, run the IoT help file:
$ aws iot help
The AWS CLI is now installed. Create a new IAM user and get API credentials from the AWS Management Console by following the steps in Getting Set Up with the AWS Command Line Interface. After you have an access ID and key, configure the AWS CLI credentials by issuing the following command:
$ aws configure
NOTE: To configure AWS IoT, ensure that your default region is set
to a region where AWS IoT is available such as us-east-1
. The
default output format can be left as JSON.
In order to get permission to download the AWS IoT tools, attach the administrator account policy to the user. In the IAM console, in the Users panel, select the user you created, attach the policy, and then select the administrator account.
In terms of AWS IoT, your Intel Edison device is a thing. To start registering your Edison with AWS IoT, issue the following command:
$ aws iot create-thing --thing-name myEdison
-
Create a folder where your certificates will be stored:
$ cd ~ $ mkdir aws_certs $ chmod 700 aws_certs $ cd aws_certs
-
A client certificate must be generated to authenticate to the AWS IoT topic with MQTT. Run the following to create the certificate:
$ aws iot create-keys-and-certificate \ --set-as-active \ --certificate-pem-outfile my_certificate.pem \ --public-key-outfile my_public_key.pem \ --private-key-outfile my_private_key.pem
-
At the top of the output, locate the
certificateArn
property. Copy the value, which has a pattern ofarn:aws:iot:<region>:<accountId>:cert/<certificateId>
. You will use this value when you attach the certificate to the AWS IoT policy.
Create a JSON policy document for the AWS IoT SDK. For more information about AWS IoT policies, see Authorization in the service documentation.
The following policy allows all IoT actions and should be used for development purposes only.
-
Copy the following text (CTRL+C):
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iot:*" ], "Resource": [ "*" ] } ] }
-
Enter
vi policy.json
, hit "a", and right-click to paste the text. -
Press ESC and type in
:wq
to save and quit. -
Create the IoT policy by issuing the following command:
$ aws iot create-policy \ --policy-name EdisonPubSubToAnyTopic \ --policy-document file://policy.json
-
If you have misplaced the
certificateArn
value, you can issue the following command to locate it:$ aws iot list-certificates
-
Attach the policy to the certificate by issuing the following command:
$ aws iot attach-principal-policy \ --principal <certificate_arn> \ --policy-name EdisonPubSubToAnyTopic