Closed pagil closed 7 years ago
A workaround of duplicating sections is described in https://github.com/aws/aws-sdk-java/issues/803
I'm not sure that we can fix this without the possibility of breaking customers.
We need to continue to support the current behavior and if we add a check that looks up "profile test" if "test" was inputted and returned null then we could start reading profiles that are out of date or unwanted.
I'll sync with the team to see what we want to do here.
Just had this issue. I'd suggest you check [profile xxxx] first and if not found then try [xxxx] or the other way around. anyone using named profiles from the java sdk over default ( guessing a small amount ) will likely already be dealing with this. Most of the time i'm just dealing with this locally and on prod it finds the region of the machine its running on.
In general all this "automatic" stuff would be nice to turn off as it can be super confusing what is going on. Some kind of explicit way to trigger these paths outside of just calling .build() on service outside of a try/catch would be nice.
We will be fixing the "profile" prefix behavior for credential and region loading in V2 of our SDK to be consistent with the way the CLI works: https://github.com/aws/aws-sdk-java-v2/issues/31
We're not able to make this change in 1.11 because of the risk of breaking customers that rely on the current behavior.
SUMMARY
The following article introduced new API which should be used to load AWS credentials and region: https://aws.amazon.com/blogs/developer/client-constructors-now-deprecated/
However, when the following API is used:
Exception
com.amazonaws.SdkClientException: Unable to load region information from any provider in the chain
is thrown.Steps to reproduce
Create a new gradle Java project.
Add the following dependencies:
Create a new class and add the following main method in it:
Make sure you set environment variable
AWS_PROFILE=test
.Add the following lines into your
~/.aws/config
file:(Optional and not relevant to the bug) Add the following lines into your
~/.aws/credentials
file:Run the class with the environment variable
AWS_PROFILE=test
and check the console.I get the following console output:
IMPORTANT
Region cannot be loaded from
~/.aws/config
file becauseaws-java-sdk-core
searches the values in the~/.aws/config
file by keytest
notprofile test
. Prefix'profile '
is missing.This is a bug, because
~/.aws/config
file keys should have'profile '
prefix if they are different fromdefault
. For example, this article demonstrates the format of the~/.aws/config
file:http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html
WORKAROUNDS
Add the following lines into
~/.aws/config
file:Note the difference:
[test]
instead of[profile test]
. This is the format of the~/.aws/credentials
file.Set environment variable
AWS_REGION=test
in addition toAWS_PROFILE=test
.Use old deprecated API:
NOTES
I have also tried the newest versions of the libraries:
The issue is reproducible with the newest available versions of the libraries.