ProfileCredentialsProvider

A CredentialsProvider that gets credentials from a profile in ~/.aws/config or the shared credentials file ~/.aws/credentials. The locations of these files are configurable via environment or system property on the JVM (see AwsSdkSetting.AwsConfigFile and AwsSdkSetting.AwsSharedCredentialsFile).

This provider is part of the DefaultChainCredentialsProvider and usually consumed through that provider. However, it can be instantiated and used standalone as well.

NOTE: This provider does not implement any caching. It will reload and reparse the profile from the file system when called. Use CachedCredentialsProvider to decorate the profile provider to get caching behavior.

This provider supports several credentials formats:

Credentials defined explicitly within the file

[default]
aws_access_key_id = my-access-key
aws_secret_access_key = my-secret

Assumed role credentials loaded from a credential source

[default]
role_arn = arn:aws:iam:123456789:role/RoleA
credential_source = Environment

Assumed role credentials from a source profile

[default]
role_arn = arn:aws:iam:123456789:role/RoleA
source_profile = base

[profile base]
aws_access_key_id = my-access-key
aws_secret_access_key = my-secret

Other more complex configurations are possible. See the Configuration and credential file settings documentation provided by the AWS CLI.

Parameters

profileName

Override the profile name to use. If not provided it will be resolved internally via environment (see AwsSdkSetting.AwsProfile) or defaulted to default if not configured.

region

The AWS region to use, this will be resolved internally if not provided.

platformProvider

The platform API provider

httpClient

the HttpClientEngine instance to use to make requests. NOTE: This engine's resources and lifetime are NOT managed by the provider. Caller is responsible for closing.

configurationSource

An optional configuration source to use for loading shared config. If not provided, it will be resolved from the environment.

Constructors

Link copied to clipboard
constructor(profileName: String? = null, region: String? = null, platformProvider: PlatformProvider = PlatformProvider.System, httpClient: HttpClientEngine? = null)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val profileName: String? = null
Link copied to clipboard
val region: String? = null

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open suspend override fun resolve(attributes: Attributes): Credentials
Link copied to clipboard
open override fun toString(): String