1

I’m trying to test a Java app running in a docker container on my desktop. The app runs fine if I execute it directly from my command line, but it fails when I try to run it inside a Docker container on my desktop. The error output shows that the library is requesting region information, then failing with this error:

com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.

I am providing the region as an environment variable:

AWS_DEFAULT_REGION=us-east-2

If I hard-code the region, it works fine. (The library is successfully extracting the credentials from environment variables.)

danorton
  • 11,804
  • 7
  • 44
  • 52

2 Answers2

3

AWS is inconsistent in its implementation for this, as sometimes AWS_DEFAULT_REGION is required, other times AWS_REGION is required. For the AWS API for Java, use AWS_REGION. (Specify both to work in all situations.)

[h/t John Camerin who revealed this answer in comments on similar questions.]

cf. 44151982, 36354423, Github aws/aws-sdk-go#2103

danorton
  • 11,804
  • 7
  • 44
  • 52
0

You need to set AWS_REGION, not AWS_DEFAULT_REGION. Default Region Provider Chain

Jason Wadsworth
  • 8,059
  • 19
  • 32
  • AWS_DEFAULT_REGION works in python boto3 and the cdk. AWS_REGION doesn't work for boto, cdk. The name kind of make you think they would complement each other but that's isn't true. For python it's this and java it's that while people work in multiple languages at a time. Such a mess. – Khoa Aug 12 '21 at 00:49