Wrapper library for python boto3.session.Session.
Project description
boto3-session
A wrapper library for the boto3.session.Session class in Python.
Requirement
- Python versions >=3.9
- uv (for development purposes)
Installation
To install boto3-session, run the following command:
$ pip install boto3-session
Usage
boto3_session.Session can be used similarly to boto3.Session:
from boto3_session import Session
session = Session()
s3 = session.resource('s3')
bucket = s3.Bucket(...)
...
The some of parameters for boto3_session.Session are akin to those for boto3.Session:
profile_name: The AWS profile name.aws_access_key_id: The AWS access key ID.aws_secret_access_key: The AWS secret access key.aws_session_token: The AWS session token.region_name: The AWS region name.
Additionally, boto3_session.Session supports management of AssumeRole:
role_arn: The AWS role ARN for AssumeRole. If set, aws_access_key_id, aws_secret_access_key, and aws_session_token are replaced with the AssumeRole credentials.session_name: The AWS session name, defaulting to "boto3_session".
boto3_session.Session includes client and resource methods, like boto3.Session. By default, the following configuration is passed to them:
Config(retries={'max_attempts': self.max_attempts, 'mode': self.retry_mode})
In boto3, the default values for max_attempts and mode are 5 and legacy, respectively. In boto3_session, they default to 3 and "standard".
These defaults can be overridden by passing the following parameters to boto3_session.Session:
retry_mode: The retry mode for failed requests, defaulting to "standard".max_attempts: The maximum number of retry attempts for failed requests, defaulting to 10.
For SSO login:
use_device_code: A boolean flag to force the use of the device authorization flow for SSO login. Defaults to False.
See the next section for details.
SSO Login
For configurations with SSO login, if the token is absent or expired,
boto3_session.Session automatically orchestrates an IAM Identity Center login
flow. By default the library re-implements the AWS CLI v2 PKCE authorization
code flow (version 2.22.0 and newer) and opens the one-time verification URL in
your browser. If the interactive flow cannot run for some reason, it falls
back to invoking aws sso login.
If you need to force the older device authorization flow (for example when the
browser-based PKCE flow is not available), set the use_device_code flag when
creating the session:
Session(use_device_code=True)
This mirrors the --use-device-code option introduced in modern AWS CLI
releases.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file boto3_session-0.2.2.tar.gz.
File metadata
- Download URL: boto3_session-0.2.2.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
52a28a00611ebef41669f794df227cf2ebac205883b262ccd24656fbdc675189
|
|
| MD5 |
419b833fdd2833c1aa60bffc63489deb
|
|
| BLAKE2b-256 |
5782372e52e9ffa1a9a0097bbb79454ccd14c1f996ecc4e062e963fd54843932
|
File details
Details for the file boto3_session-0.2.2-py3-none-any.whl.
File metadata
- Download URL: boto3_session-0.2.2-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
535f5b3ebccc49c8a7c67213fc7300bd72fee48c85b99018109960beb30d3975
|
|
| MD5 |
a035d5d6c2ca337f446759bd18628fcf
|
|
| BLAKE2b-256 |
ea0f060f8014f89de3943b6dcae880c1a9620f0a492094b6791c2a28d432139d
|