Extensions to the AWS SDK for Python
Slowing down. Last release over 3 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install boto3-extensionsBoto3 Extensions
Overview
This module adds more resource files to the Boto3 library and includes some functionality enhancements.
Quick Start
First, install the library:
$ pip install boto3_extensions
Follow the Boto3 docs on setting up your region and credentials (https://github.com/boto/boto3).
Then, from a Python interpreter:
import boto3
import boto3_extensions
r = boto3.resource('cloudtrail', region_name='us-east-1')
for trail in r.trails.all():
print(trail.trail_arn)
Resource Files
The following resource files are added to the Boto3 library.
- acm
- autoscaling
- cloudfront
- cloudtrail
- cur
- datapipeline
- directconnect
- elasticache
- elb
- elbv2
- emr
- glue
- health
- kinesis
- lambda
- rds
- redshift
- route53
- support
The following resource files are updated in the Boto3 library.
- dynamodb
- ec2
- iam
- s3
RefreshableAssumeRoleProvider
If your code needs to AssumeRole into another role before performing actions against the AWS API (be it in the same or another AWS account), you run the risk that the credentials you are using expire during their use. You can either add code to your application to constantly check the credential expiry time or using this extension offload the credential refresh to boto3 itself. By using the ConnectionManager in boto3_extensions not only will it automattically assumeRole when the credentials get below 15 mins left, but it will also cache the credentials. This means that if your application is calling boto3 to get credentials for another role more than once the ConnectionManager will cache the first call and then hand out the same session for the subsequent calls.
role_arn = 'arn:aws:iam::1234567890:role/test-role'
role_session_name = 'test'
connections = boto3_extensions.ConnectionManager(region_name='us-east-1')
session = connections.get_session(role_arn=role_arn, role_session_name=role_session_name)
r = session.resource('cloudtrail', region_name='us-east-1')
for trail in r.trails.all():
print(trail.trail_arn)
