Package: pyawsutils
pyawsutilspyawsutils is a collection of utilities for interacting with Amazon Web Services.Overviewpyawsutils is available:install using pip from pypi:https://pypi.org/project/pyawsutilsbrowse source code on github:https://github.com/microchip-pic-avr-tools/pyawsutilsread API documentation on github:https://microchip-pic-avr-tools.github.io/pyawsutilsread the changelog on github:https://github.com/microchip-pic-avr-tools/pyawsutils/blob/main/CHANGELOG.mdUsagepyawsutils 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 interfacepyawsutils has 4 actions with different options. See help and examples below for more details.Getting help:pyawsutils--helpregister-mar actionThe register-mar action supports AWS Multi account registration(MAR) of your device certificate(s) with your AWS profile.Example:pyawsutilsregister-mar-cmycertificate.pem--policy-namemypolicyregister-jitr actionThe register-jitr action setup an AWS account for Just in time registration(JITR) with your AWS profile. A cloudformation stack(MCHPStack) is created including a lambda function that registers the device when it connects for the first time.Example:pyawsutilsregister-jitrcreate-policy actionThe create-policy action lets you create policies that can be used with your MAR setup and AWS IoT account.Example:pyawsutilscreate-policy--policymypolicy.json--policy-namemypolicyClean actionThe clean action let you delete all device certificates, things and policies in an AWS IoT account with your AWS profile. Note: CA certificates are not deleted. Other services like cloudformation stacks are also not deleted.Example:pyawsutilscleanLibrarypyawsutils can be used as a library by instantiating any of the contained classes.Register device for custom provisioning with MARThemarmodule enables registering a device in AWS by using multi account registration(MAR). Thepolicymodule contains policy helper functions. For example:frompyawsutils.marimportaws_marfrompyawsutils.policyimportPolicydevice_cert_file="my_device.crt"my_policy="my_policy"templatefile="my_policytemplate.json"# Read policy template filewithopen(templatefile,"r")asmyfile:policy_template=myfile.read()# Create AWS policyaws_policy_tool=Policy()aws_policy_tool.create_policy(my_policy,policy_template)# Register device certificate without CA for custom provisioning with MAR.aws_mar_tool=aws_mar()aws_mar_tool.create_device(certificate_file=device_cert_file,policy_name=my_policy,thing_type=None)Register signer with AWS for custom provisioningTheregister_signermodule enables registering a signer in the AWS cloud.frompyawsutils.register_signerimportregister_signer# Register signer with AWS. For custom provisioning only.register_signer(signer_ca_key_path=signer_ca_key_file,signer_ca_cert_path=signer_ca_cert_file,signer_ca_ver_cert_path=signer_ca_ver_cert_file,aws_profile="default")Setup an AWS Just-in-Time Registration(JITR) accountTheaws_cloudformationmodule contains functions using AWS Cloudformation to setup a JITR account. Example setting up a lambda function with JITR code.frompyawsutils.aws_cloudformationimportsetup_aws_jitr_account# Setup AWS account for JITR, using Cloudformation and uploading Lambda pack with JITR codesetup_aws_jitr_account(force=force_setup)Cleaner utilityThecleanmodule contains functions to delete certificates, things and policies from your account.frompyawsutils.cleanimportAccountCleanerclean_tool=AccountCleaner(profile_name)clean_tool.cleanup()Versioningpyawsutils version can be determined by:frompyawsutilsimport__version__aspyawsutils_versionprint(f"pyawsutils version{pyawsutils_version}")Changelog[1.2] - December 2023AddedDSG-5731 Help improvementsFixedDSG-5640 Clean up unused pyedbglib dependencies / requirementsDSG-5714 pyawsutils clean action should also delete MCHPStackDSG-5722 Profile not taken into account when doing cloud formationDSG-5729 Bug/typo in usage example for pyawsutils create-policyDSG-6131 PEP-0440 compliance for pyawsutils[1.1.0] - October 2022FixedDSG-5683 Updated AWS JITR Lambda Python runtime 3.6 -> 3.9[1.0.0] - June 2022AddedDSG-5013 Added Amazon root CA bundle as recommended by AmazonDSG-4397 Added readme linkDSG-4471 Added changelog linkFixedDSG-4361 Clean action does not delete any policiesDSG-5023 Replaced find_packages with find_namespace_packages[0.11.6] - December 2021AddedDSG-4071 Publication to GitHubDSG-4192 Sphinx documentation[0.10.0] - February 2021First public release to PyPi