Skip to main content

Extensions to the AWS SDK for Python

Project description

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)

ARN Patch

It would be nice to have a consistent way to get the ARN of resources. The ARN patch feature of boto3_extensions allows you to get the arn from resources via an arn attribute.

>>> import boto3
>>> import boto3_extensions
>>> from imp import reload
>>> boto3_extensions.arn_patch_boto3()
>>> reload(boto3)
>>>
>>> r = boto3.resource('rds', region_name='us-east-1')
>>> for db in r.db_instances.all():
>>>   print(db.arn)

Getting Help

Please raise issue ticket inside our Bitbucket repo: https://bitbucket.org/atlassian/boto3_extensions/issues

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boto3_extensions-0.12.1.tar.gz (27.5 kB view details)

Uploaded Source

File details

Details for the file boto3_extensions-0.12.1.tar.gz.

File metadata

  • Download URL: boto3_extensions-0.12.1.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.4.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.6

File hashes

Hashes for boto3_extensions-0.12.1.tar.gz
Algorithm Hash digest
SHA256 117f5503522e30539103c39e7d03d75635ca91352747327d0963f4f81064bc03
MD5 a01626f7639dd26eea06baf8dac09f8e
BLAKE2b-256 26b82bfa69aa8adfb6e4422fbb30baa86115e67af4d4cd446761081aae070706

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page