Python AWS SDK boto3 library enhancement
Project description
Welcome to boto_session_manager Documentation
Feature
Boto Client Enum
Provide an Enum class to access the aws service name to create boto client.
from boto_session_manager import BotoSesManager, AwsServiceEnum
bsm = BotoSesManager()
s3_client = bsm.get_client(AwsServiceEnum.S3)
Cached Client
Once an boto session is defined, each AWS Service client should be created only once in most of the case. boto_session_manager.BotoSesManager.get_client(service_name) allow you to fetch the client object from cache if possible.
from boto_session_manager import BotoSesManager, AwsServiceEnum
bsm = BotoSesManager()
s3_client1 = bsm.get_client(AwsServiceEnum.S3)
s3_client2 = bsm.get_client(AwsServiceEnum.S3)
assert id(s3_client1) = id(s3_client2)
Assume Role
Create another boto session manager based on an assumed IAM role. Allow you to check if it is expired and maybe renew later.
bsm_assumed = bsm.assume_role("arn:aws:iam::669508176277:role/sanhe-assume-role-for-iam-test")
sts_client = bsm_assumed.get_client(AwsServiceEnum.sts)
print(sts_client.get_caller_identity())
print(bsm_assumed.is_expired())
Install
boto_session_manager is released on PyPI, so all you need is:
$ pip install boto_session_manager
To upgrade to latest version:
$ pip install --upgrade boto_session_manager
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 Distribution
boto_session_manager-0.0.3.tar.gz
(20.3 kB
view hashes)
Built Distribution
Close
Hashes for boto_session_manager-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | df9d46c7cd43a8e27786b439a0e6ba68d64d9a9f40528d32478145131a131c24 |
|
MD5 | 0f556d69dd94c80ce8b35836105562f9 |
|
BLAKE2b-256 | 8afb53313ad6dba58a69d5fd6bbfadcb8372c0687833b6cd3b0f84f4af2691d2 |
Close
Hashes for boto_session_manager-0.0.3-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ddc003c18fb7a8d2e7b376c26e62b849ae2dfd910a72ececf2eb8ac26f7e25b |
|
MD5 | c4b6dfeabd16e545809c1351713e8892 |
|
BLAKE2b-256 | 292403f4fe569ce3ab0f9327dcb2a9a954fc54283bd8eb898894cc02e57546fc |