handtruck.credentials

class handtruck.credentials.AbstractCredentials[source]

Bases: ABC

abstract property signer: AwsRequestSigner
class handtruck.credentials.ConfigCredentials(credentials_path: str | Path | None = None, config_path: str | Path | None = PosixPath('/home/docs/.aws/config'), *, region: str = '', service: str = 's3', profile: str = 'auto')[source]

Bases: StaticCredentials

Credentials from the awscli config

By default, these come from ~/.aws/credentials and ~/.aws/config, but this is customizable with $AWS_SHARED_CREDENTIALS_FILE, $AWS_SHARED_CONFIG_FILE, and $AWS_PROFILE.

DEFAULT_CONFIG_PATH = PosixPath('/home/docs/.aws/config')
DEFAULT_CREDENTIALS_PATH = PosixPath('/home/docs/.aws/credentials')
class handtruck.credentials.EnvironmentCredentials(region: str = '', service: str = 's3')[source]

Bases: StaticCredentials

Credentials, read in from the standard environment variables.

class handtruck.credentials.MetadataCredentials(*, service: str = 's3')[source]

Bases: AbstractCredentials, AsyncContextManagerMixin

Credentials from the AWS metadata service.

This only works inside of AWS, and unlike everything else, is dynamic and kept fresh. The context manager manages this process:

with MetadataCredentials() as creds:
    client = S3Client(..., credentials=creds)
METADATA_ADDRESS: str = '169.254.169.254'
METADATA_PORT: int = 80
property signer: AwsRequestSigner
class handtruck.credentials.StaticCredentials(access_key_id: str = '', secret_access_key: str = '', session_token: str | None = None, region: str = '', service: str = 's3')[source]

Bases: AbstractCredentials

Simple, constant credentials, passed in from elsewhere.

access_key_id: str = ''
as_dict() dict[source]
region: str = ''
secret_access_key: str = ''
service: str = 's3'
session_token: str | None = None
property signer: AwsRequestSigner[source]
class handtruck.credentials.URLCredentials(url: str | URL, *, region: str = '', service: str = 's3')[source]

Bases: StaticCredentials

Credentials, where the access key and secret are in the URL.

handtruck.credentials.collect_credentials(*, url: URL | None = None, **kwargs) StaticCredentials[source]

Calls merge_credentials() on the set of standard credential sources.

If you want to emulate awscli, use this.

handtruck.credentials.merge_credentials(*credentials: StaticCredentials) StaticCredentials[source]

Reads a bunch of credentials and produces a StaticCredentials.