How does it work in detail: AWS IoT Device SDK, AWS IoT, Thing Registry, Security, Rules Engine, Connecting to other AWS Services.

The AWS IoT Device SDK for Python allows developers to write Python script to use their devices to access the AWS IoT platform through MQTT or MQTT over the WebSocket protocol. By connecting their devices to AWS IoT, users can securely work with the message broker, rules, and the device shadow (sometimes referred to as a thing shadow) provided by AWS IoT and with other AWS services like AWS Lambda, Amazon Kinesis, Amazon S3, and more.

The following examples are based on the AWS IoT Device SDK for Python.

Provisioning a device to work with AWS IoT

Quickstart to provision a thing including code from the AWS IoT console. This thing uses the AWS IoT Device SDK for Python.

AWS IoT Console -> Get started or Connect
Connect to AWS IoT -> View connection options
Configuring a device -> Get started
Get started
Choose Linux/OSX and Python -> Next
Name: "myFirstIoTDevice" -> Next step
Download -> Linux/OSX
Next step

Copy the package just downloaded to your device and follow the instructions on the page that is shown in the AWS IoT console.

You should see messages arriving in the AWS IoT console.

Send a message to your device:

Step 4: Send a messages to the device: Type something -> Send message

Done

Thing Registry

Find your "myFirstIoTDevice" in the Console Thing Registry

Security

Find certificate for your IoT Device in the Console Security

Policy attached to the device

Click the certificate -> Policies

Watch the contents of the policy

Click on myFirstIoTDevice-Policy

You can also bring your own CA to AWS IoT.

Rules Engine - Connecting to other AWS Services

Data comming into AWS IoT can be transfered by the Rules Engine to other services by using SQL. Permission must be granted to AWS IoT to access the service where the data should be transfered to.

Data can be transfered by AWS IoT topic rules to:

topic_rules_actions.png

Send sensor data from SenseHat to AWS IoT

Copy basicPubSubSenseHat.py onto your device (e.g. RPi).

Modify "start.sh" to start "basicPubSubSenseHat.py"

Replace "aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py"
with
"basicPubSubSenseHat.py"

Go to the AWS IoT console

Test 
Subscribe to "sdk/test/Python" and "$aws/events/#"

On your device:

Launch start.sh 
Watch at the MQTT client in AWS IoT
Stop the script