aws/aws-sdk-go

Use `AWS_DEFAULT_REGION` not `AWS_REGION`

delitescere opened this issue · 5 comments

WithRegion(os.Getenv("AWS_REGION")).

According to https://docs.aws.amazon.com/cli/latest/userguide/cli-environment.html there is now a "standard" (unfortunately many API clients do indeed use AWS_REGION).

Suggest only using AWS_REGION if AWS_DEFAULT_REGION is not blank.

xibz commented

Hello @delitescere, thank you for reaching out to us. This would be a breaking change for the SDK and something we would not be able to support without introducing another environment variable. This is just an inconsistency of how SDKs handle environment variable. In addition, AWS_DEFAULT_REGION was introduced later, which is why the behavior is the way that it is. Since this is a breaking change, I will go ahead and close this. I suggest using AWS_REGION for both the CLI and the SDK. If you have any other issues, please let us know!

Thanks @xibz! Yes I definitely know the annoyance that the names of these configuration variables causes - I have several variations of the same values depending on what the client expects.

Although, I don't know that my suggestion makes it a breaking change. Falling back to AWS_REGION if AWS_DEFAULT_REGION is blank seems like nice backwards compatibility and pushing towards eventual uniformity?

@delitescere thanks for the feedback. The reason the change in behavior is the SDK looks at AWS_REGION first and only AWS_DEFAULT_REGION next if the SDK's support for the shared config is enabled via the session or AWS_SDK_LOAD_CONFIG=1 env is set.

The SDK requires an option support for the shared config files since its feature were added after the SDK initial released. Automatically supporting the shared config would of potentially change the behavior of user applications that were running in the same environment as the AWS CLI.

By the way, it seems the CLI has dropped support for AWS_REGION now, which lead to some confusion since I was expecting both to work. After a quick search I actually can't find anything mentioning this (changelogs, git commits) in either boto3 or the awscli repository. I just observe that AWS_REGION isn't mentioned in the aws-cli documentation and doesn't work anymore.

FWIW I would like to see these tools behave as consistently as possible, though I understand the pressure to remain backwards compatible. Perhaps pressure should be applied to awscli to re-support AWS_REGION?

hello can anyone send get the all instances from all regions using go.