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 /)
Mac Python 3.8.2
git clone https://github.com/aws/aws-iot-device-sdk-python-v2.git
pip install ./aws-iot-device-sdk-python-v2
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
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.
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