Python AWS Helper Library
Project description
PyAwsHelper
Python AWS Helper Library
AWS Region Helper
Get Boto3 Client and Resource with refreshable session
from PyAwsHelper.boto_helper import BotoHelper
helper = BotoHelper()
# Both client is sharing common refreshable session
s3_client = helper.get_client(service_name="s3", region_name="us-east-1", role_arn="arn:aws:iam::123:role/my_db_role")
db_client = helper.get_client(service_name="dynamodb", region_name="us-east-1", role_arn="arn:aws:iam::123:role/my_db_role")
Use Raw Refreshable session to implement your need
# can use BotoHelper to get session
from PyAwsHelper.boto_helper import BotoHelper
helper = BotoHelper()
s3_client = helper.get_session(region_name="us-east-1", role_arn="arn:aws:iam::123:role/my_db_role")
# or can directly access raw BotoSession module
from PyAwsHelper.boto_session import BotoSession
session = BotoSession().refreshable_session()
client = session.client("s3") # we now can cache this client object without worrying about expiring credentials
Get AWS region from region suffix
from PyAwsHelper.region import Region
aws_region = Region.get_region("va")
>>> aws_region
'us-east-1'
Also supports providing default value
from PyAwsHelper.region import Region
aws_region = Region.get_region("foo", default_region="bar")
>>> aws_region
'bar'
Get region suffix from AWS region
from PyAwsHelper.region import Region
aws_region = Region.get_region_suffix("us-east-1")
>>> aws_region
'va'
Also supports providing default value
from PyAwsHelper.region import Region
aws_region = Region.get_region_suffix("foo", default_region_suffix="bar")
>>> aws_region
'bar'
Regions Config
{
"hk": "ap-east-1", # Hong Kong
"tk": "ap-northeast-1", # Tokyo
"se": "ap-northeast-2", # Seoul
"os": "ap-northeast-3", # Osaka-Local
"mu": "ap-south-1", # Mumbai
"sg": "ap-southeast-1", # Singapore
"sy": "ap-southeast-2", # Sydney
"au": "ap-southeast-2", # Sydney
"ce": "ca-central-1", # Central
"be": "cn-north-1", # Beijing
"ni": "cn-northwest-1", # Ningxia
"fr": "eu-central-1", # Frankfurt
"st": "eu-north-1", # Stockholm
"ir": "eu-west-1", # Ireland
"lo": "eu-west-2", # London
"pa": "eu-west-3", # Paris
"ba": "me-south-1", # Bahrain
"sp": "sa-east-1", # São Paulo
"va": "us-east-1", # N. Virginia
"va-gov": "us-gov-east-1",
"oh": "us-east-2", # Ohio
"ca": "us-west-1", # N. California
"nc": "us-west-1", # N. California
"ca-gov": "us-gov-west-1",
"nc-gov": "us-gov-west-1",
"or": "us-west-2", # Oregon
}
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
PyAwsHelper-0.0.3.tar.gz
(5.7 kB
view details)
Built Distribution
File details
Details for the file PyAwsHelper-0.0.3.tar.gz
.
File metadata
- Download URL: PyAwsHelper-0.0.3.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb2aafc1dd8dea20d5f8c8f9f901eccbf3729ee86021a1307d97da51b7aaf77e |
|
MD5 | 1752c178763ad59f983454d39a863658 |
|
BLAKE2b-256 | f3aff087b6cd4057f03ba933d02e02b9099d21bd7b979e9eca699e91c4ee75d0 |
File details
Details for the file PyAwsHelper-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: PyAwsHelper-0.0.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dd3bb6bcdaa38cc7c39794431ff02eb214fa5163ee602fc178ce1f293a29c21 |
|
MD5 | d7c6ef1e2b1d81a41c3bdefc7a20e74c |
|
BLAKE2b-256 | 9edad5069be7d29adf923cc2a07cdf42b6b86e68035a33819fb5e86f06836aa0 |