skillfed

aws-assume-role-lib

Assumed role session chaining (with credential refreshing) for boto3

aws-assume-role-lib v2.10.0 622.9K downloads/30d#5,706 on PyPI162
Permissive license Apache-2.0 Abandoned released

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-lib

uv

uv add aws-assume-role-lib

poetry

poetry add aws-assume-role-lib

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: System AdministratorsLicense :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: LibrariesTopic :: Utilities

Tags

boto3 assume roleaws sts assume role wrapperautomatic credential refreshaws role chainingboto3 session managementlambda assume roleaws temporary credentials
awsiamcredential-management

More Libraries packages