A collection of utilities for interacting with Amazon Web Services
Project description
pyawsutils
pyawsutils is a collection of utilities for interacting with Amazon Web Services.
Usage
pyawsutils is intended as a library but could also be used stand-alone as a CLI. Its primary consumer is iotprovision. Make sure you have the AWS CLI installed and run aws configure first to setup your profile.
Command-line interface
pyawsutils has 4 actions with different options. See help and examples below for more details.
Getting help:
pyawsutils --help
register-mar action
The register-mar action support AWS Multi account registration of your device certificate(s) with your AWS profile.
Example:
pyawsutils register-mar -c mycertificate.pem --policy-name mypolicy
create-policy action
The create-policy action lets you create policies that can be used with your MAR/AWS account.
Example:
pyawsutils create-policy --policy mypolicy.json --policy-name mypolicy
Clean action
The clean action let you delete all certificates and things in your AWS account.
Example:
pyawsutils clean
Library
pyawsutils can be used as a library by instantiating any of the contained classes.
For example to perform "custom"/JITR (Just In Time Registration) provisioning:
# pyawsutils uses the Python logging module
import logging
logging.basicConfig(format="%(levelname)s: %(message)s", level=logging.WARNING)
# The target must be running provisioning firmware, pykitcommander is used to accomplish this
from pykitcommander.kitmanager import KitProgrammer, KitApplicationFirmwareProvider
# Connect to the kit programmer/debugger
programmer = KitProgrammer()
# Look up available applications for this kit
applications = KitApplicationFirmwareProvider(programmer.kit_info['kit_name'])
# Request iotprovision application
application = applications.locate_firmware("iotprovision-aws")
# Program the application using bundled firmware
programmer.program_application(application['bundled_firmware'])
# Create the protocol object for this application
protocol = application['protocol_driver']()
# Instantiate the provisioner
from pyawsutils.custom_provision import AwsCustomProvisioner
provider_provisioner = AwsCustomProvisioner("my_root_ca_cert_file",
"my_signer_ca_key_file",
"my_signer_ca_cert_file",
"generated_device_csr_file",
"generated_device_cert_file")
# Do the actual provisioning
thing_name = provider_provisioner.provision("MY_SERIAL_PORT", protocol)
The above example will generate a device certificate and save it along with the CA signer certificate in WINC flash. Generated certificates and "thing name" are saved to files as well.
Logging
This package uses the Python logging module for publishing log messages to library users.
A basic configuration can be used (see example), but for best results a more thorough configuration is recommended in order to control the verbosity of output from dependencies in the stack which also use logging.
Dependencies
This package uses pyedbglib through other libraries for USB communications. For more information see: https://pypi.org/project/pyedbglib/
Versioning
pyawsutils version can be determined by:
from pyawsutils.version import VERSION as pyawsutils_version
print("pyawsutils version {}".format(pyawsutils_version))
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for pyawsutils-0.10.0.17-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61e1fd6f8cbc8d293ee65bf6b6fb5a51d9c838cdf0a8ef83d4e0b5bbfe877984 |
|
MD5 | 5142ee434c0af6bad41571972e452d2d |
|
BLAKE2b-256 | daa82174120dc11b09580726e21c31866bf48e3a8f42f9557db385485c3bfd80 |