Skip to main content

Helpers to make using boto3 more enjoyable

Project description

What is this?

This is a util package to help making boto3 more enjoyable.

Below is a list of the use cases:

client

instead of doing:

import boto3

client = boto3.client('cloudformation')

You can do

import betterboto

with betterboto.ClientContextManager('cloudformation') as client:
    client.create_stack

Instead of doing:

import boto3 

role_arn = 'arn:aws:iam::123456789010:role/super-role'
role_session_name = 'super-role'

sts = boto3.client('sts')
assumed_role_object = sts.assume_role(
    RoleArn=role_arn,
    RoleSessionName=role_session_name,
)
credentials = assumed_role_object['Credentials']
kwargs = {
    "aws_access_key_id": credentials['AccessKeyId'],
    "aws_secret_access_key": credentials['SecretAccessKey'],
    "aws_session_token": credentials['SessionToken'],
}
client = boto3.client(
    'cloudformation',
    aws_access_key_id=credentials['AccessKeyId'],
    aws_secret_access_key=credentials['SecretAccessKey'],
    aws_session_token=credentials['SessionToken'],
)

You can do

import betterboto

with betterboto.CrossAccountClientContextManager('cloudformation', 'arn:aws:iam::123456789010:role/super-role', 'super-role') as client:
    client.create_stack

cloudformation

instead of

Project details


Download files

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

Files for better-boto, version 0.5.0
Filename, size File type Python version Upload date Hashes
Filename, size better-boto-0.5.0.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page