aws-assume-role-lib
Assumed role session chaining (with credential refreshing) for boto3
What it is and what it does
aws-assume-role-lib wraps the verbose boilerplate of AWS STS AssumeRole into a single function call on a boto3 Session. Instead of manually calling sts.assume_role(), parsing the response, and creating a new session with temporary credentials, you pass a session and role ARN to assume_role() and get back a session ready to use. The library automatically generates a role session name if you don't provide one, and crucially, it handles credential expiration by refreshing them transparently when needed—eliminating the need to call AssumeRole on every Lambda invocation or manually track credential lifetime.
The package depends only on boto3 and is designed to work across Python 3.6 through 3.10. It supports all standard AssumeRole parameters (policies, duration, external ID, tags, etc.) and lets you pass Policy as a dict instead of a JSON string, and DurationSeconds as a timedelta. For Lambda workloads, you initialize the assumed role session once outside the handler and reuse it across invocations, calling AssumeRole only when credentials actually expire.
Use it for:
- Assume an AWS role in a Lambda function once at initialization and reuse it across invocations without re-assuming on every call.
- Simplify multi-account AWS workflows by chaining role assumptions with automatic credential refresh in application code.
- Reduce boilerplate when writing boto3 scripts that need to operate under an assumed role with temporary credentials.
- Implement cross-account access patterns in microservices where each service assumes a role in another account on startup.
- Build automation tools that assume different roles for different tasks without manually managing STS calls and session creation.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Simplifies AWS role assumption in boto3 by wrapping STS AssumeRole calls into a single function that automatically refreshes expired credentials and generates session names.
Yes, if you are already using boto3 and need to assume roles programmatically. The library genuinely simplifies a common pattern and has no known vulnerabilities. However, be aware that the package is abandoned—last updated in May 2022 with no recent commits. If you need active maintenance or compatibility updates for future boto3 versions, consider whether you can afford to fork it or maintain it internally, or evaluate whether AWS's built-in profile-based role assumption in ~/.aws/config meets your needs instead.
Install
aws-assume-role-lib on PyPI
pip
pip install aws-assume-role-libuv
uv add aws-assume-role-libpoetry
poetry add aws-assume-role-libInstalling aws-assume-role-lib
Before you install
Low install friction with a single runtime dependency on boto3. However, the package is abandoned—last commit was 2022-11-02 and no releases since 2022-05-14. It remains marked Production/Stable and has no known vulnerabilities, but you will not receive updates or maintenance.
License in practice
Licensed under Apache-2.0 (permissive). You may use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
import boto3
from aws_assume_role_lib import assume_role
session = boto3.Session()
assumed_role_session = assume_role(session, "arn:aws:iam::123456789012:role/MyRole")
print(assumed_role_session.client("sts").get_caller_identity())
Requires boto3 to be installed and valid AWS credentials configured for the initial session.
Verify before relying
- Whether the package works correctly with recent boto3 versions released after 2022-05-14.
- Whether credential refresh behavior remains compatible with current AWS STS API behavior.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.6,<4.0) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — boto3 |
| Maintenance | abandoned — 1,553 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 622,935/month — #5,706 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: aws_assume_role_lib-2.10.0-py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
boto_session_managerWraps boto3 sessions with typed client…
permissive · top 5,000 on PyPI
boto3-assumeWraps boto3 to create AWS IAM assume-role…
permissive · top 15,000 on PyPI
gimme-aws-credsA CLI tool that obtains temporary AWS…
permissive · top 15,000 on PyPI
aws-sso-libProgrammatically interact with AWS IAM Identity…
permissive · top 15,000 on PyPI
placeboPlacebo records and replays AWS API calls…
permissive · top 15,000 on PyPI
arnParses AWS ARN strings into typed objects with…
unclear · top 15,000 on PyPI
requests-aws-signAdds AWS V4 request signing to the requests…
permissive · top 5,000 on PyPI
aws-msk-iam-sasl-signer-pythonGenerates IAM-signed SASL/OAUTHBEARER…
permissive · top 5,000 on PyPI
aws-cdk.aws-iamProvides Python constructs for defining AWS IAM…
permissive · top 15,000 on PyPI
eks-tokenGenerates Kubernetes authentication tokens for…
unclear · top 15,000 on PyPI