Fleet provisioning with AWS IoT SDK for Python v2

I'm looking at the README on GitHub of AWS IoT Device SDK for Python, thinking that the fleet provisioning function of AWS IoT seems to be interesting. When ## New Version Available Character is !!!

The AWS IoT SDK for Python v2 is out. https://github.com/aws/aws-iot-device-sdk-python-v2 (I'm not sure if it's called ʻAWS IoT SDK for Python v2 or ʻaws-iot-device-sdk-python-v2 or ʻAWS IoT Client SDK for Python`)

According to the README

This SDK is built on the AWS Common Runtime, a collection of libraries written in C to be cross-platform, high-performance, secure, and reliable.

That's right.

In addition, v2 already supports the fleet provisioning API and includes samples. Will v2 be the mainstream in the future?

I tried the same content in v2 as the sample introduced on the AWS blog.

[How to use fleet provisioning to automate the initial setup of IoT devices and AWS IoT Core](https://aws.amazon.com/jp/blogs/news/how-to-automate-onboarding-of-iot- devices-to-aws-iot-core-at-scale-with-fleet-provisioning /)

environment

Mac Python 3.8.2

Installing the AWS IoT SDK for Python v2

git clone https://github.com/aws/aws-iot-device-sdk-python-v2.git
pip install ./aws-iot-device-sdk-python-v2

Placement of bootstrap certificate

I placed the certificate in the following location.

console


.
├── aws-iot-device-sdk-python-v2
└── certs
    ├── bootstrap-certificate.pem.crt
    ├── bootstrap-private.pem.key
    └── root.ca.pem

Run the sample

Please modify templateName and templateParameters nicely.

cd aws-iot-device-sdk-python-v2/samples/

python fleetprovisioning.py \
  --endpoint xxxxxxxxxx.iot.ap-northeast-1.amazonaws.com \
  --root-ca ../../certs/root.ca.pem \
  --cert ../../certs/bootstrap-certificate.pem.crt \
  --key ../../certs/bootstrap-private.pem.key \
  --templateName production_template \
  --templateParameters '{"SerialNumber": 9999, "hasValidAccount": false}'

Execution result (I'm lying down or broken in places)

Connecting to xxxxxxxxxx.iot.ap-northeast-1.amazonaws.com with client ID 'samples-client-id'...
Connected!
Subscribing to CreateKeysAndCertificate Accepted topic...
Subscribing to CreateKeysAndCertificate Rejected topic...
Subscribing to RegisterThing Accepted topic...
Subscribing to RegisterThing Rejected topic...
Publishing to CreateKeysAndCertificate...
Waiting... CreateKeysAndCertificateResponse: null
Published CreateKeysAndCertificate request..
Received a new message awsiot.iotidentity.CreateKeysAndCertificateResponse(certificate_id='xxxxxxxxxx', certificate_ownership_token='xxxxxxxxxx', certificate_pem='-----BEGIN CERTIFICATE-----\nxxxxxxxxxx\n-----END CERTIFICATE-----\n', private_key='-----BEGIN RSA PRIVATE KEY-----\nxxxxxxxxxx\n-----END RSA PRIVATE KEY-----\n')
Publishing to RegisterThing topic...
Waiting... RegisterThingResponse: null
Published RegisterThing request..
Received a new message awsiot.iotidentity.RegisterThingResponse(device_configuration={}, thing_name='born_9999') 
Exiting Sample: success
Disconnecting...
Disconnected.

Reference site

https://docs.aws.amazon.com/ja_jp/iot/latest/developerguide/provision-wo-cert.html https://aws.amazon.com/jp/about-aws/whats-new/2020/04/announcing-general-availability-of-aws-iot-core-fleet-provisioning/ https://aws.amazon.com/jp/blogs/news/how-to-automate-onboarding-of-iot-devices-to-aws-iot-core-at-scale-with-fleet-provisioning/ https://qiita.com/tatsuhiroiida/items/46ef5035f99b304d3d6f

Recommended Posts

Fleet provisioning with AWS IoT SDK for Python v2
boto3 (AWS SDK for Python) Note
Run AWS IoT Device SDK for Python on Raspberry Pi
[Cloudian # 1] Try to access object storage with AWS SDK for Python (boto3)
Getting started with AWS IoT easily in Python
Call Polly from the AWS SDK for Python
AWS CDK with Python
Try using S3 object upload and download with AWS SDK for Go v2
Authentication information used by Boto3 (AWS SDK for Python)
[AWS IoT] Register things in AWS IoT using the AWS IoT Python SDK
Create a Layer for AWS Lambda Python with Docker
AWS SDK for Python (Boto3) development in Visual Studio 2017
Use AWS SDK for Python (boto) under Proxy environment
Script to easily create a client device environment for AWS IoT (Python v2 version)
Create a Twitter BOT with the GoogleAppEngine SDK for Python
Getting Started with Python responder v2
Text extraction with AWS Textract (Python3.6)
Getting Started with Python for PHPer-Classes
AWS Layer Creation Script for python
Notify HipChat with AWS Lambda (Python)
Getting Started with Python for PHPer-Functions
Use Resource API rather than Client API in AWS SDK for Python (Boto3)
[AWS] Using ini files with Lambda [Python]
Easy keyword extraction with TermExtract for Python
INSERT into MySQL with Python [For beginners]
Use DeepL with python (for dissertation translation)
Memo to ask for KPI with python
Amplify images for machine learning with python
Tips for dealing with binaries in Python
Working with OpenStack using the Python SDK
Tips for using python + caffe with TSUBAME
I want to play with aws with python
[Shakyo] Encounter with Python for machine learning
Process multiple lists with for in Python
Register users with Google Admin SDK (python)
Getting Started with Python for PHPer-Super Basics
Debug for mysql connection with python mysql.connector
[Python] Read images with OpenCV (for beginners)
Touch virtual robots with Pepper's Python SDK
Connect to s3 with AWS Lambda Python
WebApi creation with Python (CRUD creation) For beginners
Implemented Python wrapper for Qiita API v2
Preparation for scraping with python [Chocolate flavor]
Touch AWS with Serverless Framework and Python
[For beginners] Try web scraping with Python
Python + Selenium + Headless Chromium with aws lambda
The road to updating Splunkbase with your own Splunk app for Python v2 / v3
Causal reasoning and causal search with Python (for beginners)
Get a ticket for a theme park with python
[Translation] Getting Started with Rust for Python Programmers
Create a LINE BOT with Minette for Python
Building an Anaconda environment for Python with pyenv
Upgrade the Azure Machine Learning SDK for Python
Play with Lambda layer (python) for about 5 minutes
Use logger with Python for the time being
Procedure for creating a LineBot made with Python
Wrap C with Cython for use from Python
Move THORLABS automatic stage with Python [for research]
LINE BOT with Python + AWS Lambda + API Gateway
~ Tips for Python beginners from Pythonista with love ① ~
Get note information using Evernote SDK for Python 3