Developer Guide

AWS IoT SDK Tutorials

The AWS IoT Device SDKs help you to connect your devices to AWS IoT easily and quickly. The AWS IoT Device SDKs include open-source libraries, developer guides with samples, and porting guides so that you can build innovative IoT products or solutions on your choice of hardware platforms.


Before going through this tutorial, please go through the Getting Started with AWS IoT.

These tutorials provide step-by-step instructions for connecting your Raspberry Pi to the Message Broker for AWS IoT, using with the AWS IoT Device SDK for Embedded C and the AWS IoT Device SDK for JavaScript. After following these instructions, you can connect to the AWS IoT platform and run the sample applications included with the AWS IoT Device SDKs.


This tutorial requires the following:

Create an AWS IoT Thing for Your Raspberry Pi

A thing represents a device whose status or data is stored in the AWS cloud. The device's status or data is stored in a JSON document known as the device's shadow. The shadow is used to both store and retrieve state information. The Device Shadow service maintains a shadow for each device that is connected to AWS IoT.

Create an AWS IoT Thing

  1. On your Raspberry Pi, open a web browser and go to the AWS IoT console. You may be prompted to sign in.

  2. In the AWS IoT console, you see the Monitor page. In the navigation pane, choose Manage.

                        The AWS IoT console
  3. Choose Create.

                        Create an AWS IoT thing
  4. On the Creating AWS IoT things page, choose Create a single thing.

                        Create a single thing
  5. On the Add your device to the device registry page, enter MyRaspberryPi for the device Name. Leave the default values for all the other fields, and then choose Next.

                        Add your device to the device registry
  6. On the Add a certificate for your thing page, choose Create certificate. This generates an X.509 certificate and key pair.

                        Add a certificate for your thing
  7. On the Certificate created! page, download your public and private keys, certificate, and root certificate authority (CA). Save them on your Raspbery Pi, you will copy them to a different directory later on in this tutorial. Choose Activate to activate the X.509 certificate, and then choose Attach a policy.

                        Certificate created!
  8. On the Add a policy for your thing page, choose Register Thing.

    After you register your thing, you will need to create and attach a new policy to the certificate.

                        Register thing
  9. On the AWS IoT console, in the navigation pane, choose Secure and Policies. In the Policies page, choose Create a policy.

  10. On the Create a policy page:

    1. Enter a Name for the policy. For Action,

    2. enter iot:*. For Resource ARN, enter *.

    3. Under Effect, choose Allow, and then choose Create.

      This policy allows your Raspberry Pi to publish messages to AWS IoT.


      These settings are overly permissive. In a production environment narrow the scope of the permissions to that which are required by your device. For more information, see Authorization.

                                Create policy
  11. In the AWS IoT console, choose Manage and Things. On the Things page, choose MyRaspberryPi.

                        Manage MyRaspberryPi
  12. On the thing's Details page, in the left navigation pane, choose Interact.

                        MyRaspberryPi details
  13. Make a note of the REST API endpoint. You will need it to connect to AWS IoT. In the navigation pane, choose Security.

                        MyRaspberryPi interact
  14. Choose the certificate that you created earlier.

                        MyRaspberryPi security
  15. On the certificate's Details page, in Actions, choose Attach policy.

                        Certificate details
  16. On the Attach policies to certificate(s) page, choose the policy you created, and then choose Attach.

                        Attach policy to certificate