-
Notifications
You must be signed in to change notification settings - Fork 55
Description
Describe the bug
When resolving profile credentials (e.g., in a ~/.aws/credentials file), the credentials provider throws an exception if the default region resolver chain does successfully detect a region (e.g., in the profile, via env vars, etc.). This happens even if the profile credentials are purely static and don't require a region. Further note that an explicit region passed to a client constructor are unused in region resolution for the purposes of parsing profile credentials.
Expected behavior
Users with static profile credentials should be able to use those credentials successfully without the region resolver needing to detect the region.
Current behavior
Users with static profile credentials get an exception when the region resolver cannot detect the region.
Steps to Reproduce
Create an AWS profile that explicitly specifies aws_access_key_id and aws_secret_access_key but not region. Also ensure that no region is available via AWS_REGION env var, aws.region system property, or via IMDS (e.g., on EC2). Then attempt to create and use an AWS client (e.g., S3):
S3Client
.fromEnvironment {
region = "us-west-2"
}
.listBuckets { } // throws exception because no credentials can be resolvedWorkarounds that do succeed include adding region to the AWS profile or explicitly providing a region to an explicitly-chosen profile credentials provider:
S3Client
.fromEnvironment {
region = "us-west-2"
credentialsProvider = ProfileCredentialsProvider(region = "us-west-2")
}
.listBuckets { }Possible Solution
Remove the requirement that a region resolves correctly for static credentials which do not require a region.
Context
No response
AWS Kotlin SDK version used
0.14.2-beta
Platform (JVM/JS/Native)
JVM
Operating System and version
AL2