Force AWS library to obtain region from environment inside docker cluster

只愿长相守 提交于 2020-04-17 22:40:46

问题


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.)


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/60532462/force-aws-library-to-obtain-region-from-environment-inside-docker-cluster

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!