Skip to main content

aws-credentials-sts

This package provides STS-based credential resolvers and a chain provider:

  • AssumeRoleCredentialsResolver - assumes an explicit role_arn using credentials from a source_resolver.
  • ProfileAssumeRoleCredentialsResolver - assumes a role configured in a named profile in the shared config/credentials files.

Installation

uv pip install aws-credentials-sts

Once installed, the provider registers itself with the SDK's modular credential chain. When a client resolves credentials through the default chain, it will attempt to assume the role configured in the active profile (role_arn/source_profile/credential_source), unless a higher-precedence source resolves credentials first.

Client Configuration

To use this resolver explicitly, set the aws_credentials_identity_resolver property on a service client's config to an AssumeRoleCredentialsResolver instance. It assumes role_arn using credentials from the source_resolver:

from aws_credentials_sts import AssumeRoleCredentialsResolver
from smithy_aws_core.identity import EnvironmentCredentialsResolver

service_client = ServiceClient(
    config=ServiceClientConfig(
        aws_credentials_identity_resolver=AssumeRoleCredentialsResolver(
            source_resolver=EnvironmentCredentialsResolver(),
            role_arn="arn:aws:iam::123456789012:role/example-role",
        ),
    )
)

To assume the role defined in a named profile instead, use ProfileAssumeRoleCredentialsResolver with a MergedConfig loaded from the shared config/credentials files:

from aws_credentials_sts import ProfileAssumeRoleCredentialsResolver
from smithy_aws_core.config import load_config


async def build_client() -> ServiceClient:
    return ServiceClient(
        config=ServiceClientConfig(
            aws_credentials_identity_resolver=ProfileAssumeRoleCredentialsResolver(
                profile_name="my-profile",
                config_file=await load_config(),
            ),
        )
    )

Standalone

Either resolver can also be used on its own to fetch credentials directly:

import asyncio

from aws_credentials_sts import AssumeRoleCredentialsResolver
from smithy_aws_core.identity import EnvironmentCredentialsResolver


async def main() -> None:
    resolver = AssumeRoleCredentialsResolver(
        source_resolver=EnvironmentCredentialsResolver(),
        role_arn="arn:aws:iam::123456789012:role/example-role",
    )
    identity = await resolver.get_identity(properties={})


asyncio.run(main())

Release files for aws-credentials-sts 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aws-credentials-sts 0.2.0
File Size Uploaded
aws_credentials_sts-0.2.0.tar.gz 5.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for aws-credentials-sts 0.2.0
File Interpreter ABI Platform
aws_credentials_sts-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / aws_credentials_sts-0.2.0.tar.gz

Download URL aws_credentials_sts-0.2.0.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
090e345de890565213f83837bc1b33f2120cbe48221ca898f7013adb01abadf3
BLAKE2b-256 checksum
How to use checksums
1c9203a2b7ef80b76d7eb65081eb7cb3f85b3f4a3dd7d2768ab436654e69b6c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / aws_credentials_sts-0.2.0-py3-none-any.whl

Download URL aws_credentials_sts-0.2.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7af83393619b0486dca8dfc48f12ad89d12170a21f4fc9728f227f152eec3b00
BLAKE2b-256 checksum
How to use checksums
b37ae4250c7c99105cc3280dc2da6ca7c8dd4ceb1ef89d47c649631ca7b99a5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Amazon Linux","version":"2023","id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.3.0

2 release files

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page