SsoCredentialsProvider
CredentialsProvider that uses AWS Single Sign-On (AWS SSO) to source credentials. The provider is expected to be configured for the AWS Region where the AWS SSO user portal is hosted.
The provider does not initiate or perform the AWS SSO login flow. It is expected that you have already performed the SSO login flow using (e.g. using the AWS CLI aws sso login
). The provider expects a valid non-expired access token for the AWS SSO user portal URL in ~/.aws/sso/cache
. If a cached token is not found, it is expired, or the file is malformed an exception will be thrown.
Instantiating AWS SSO provider directly
You can programmatically construct the AWS SSO provider in your application, and provide the necessary information to load and retrieve temporary credentials using an access token from ~/.aws/sso/cache
.
val source = SsoCredentialsProvider(
accountId = "123456789",
roleName = "SsoReadOnlyRole",
startUrl = "https://my-sso-portal.awsapps.com/start",
ssoRegion = "us-east-2"
)
// Wrap the provider with a caching provider to cache the credentials until their expiration time
val ssoProvider = CachedCredentialsProvider(source)
It is important that you wrap the provider with CachedCredentialsProvider if you are programmatically constructing the provider directly. This prevents your application from accessing the cached access token and requesting new credentials each time the provider is used to source credentials.
Additional Resources
Parameters
The AWS account ID that temporary AWS credentials will be resolved for
The IAM role in the AWS account that temporary AWS credentials will be resolved for
The start URL (also known as the "User Portal URL") provided by the SSO service
The AWS region where the SSO directory for the given startUrl is hosted.
The SSO Session name from the profile. If a session name is given an SsoTokenProvider will be used to fetch tokens.
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.
The platform provider
The source of time for the provider