aws-sso-cli icon indicating copy to clipboard operation
aws-sso-cli copied to clipboard

`aws-sso eval` should set/unset `AWS_REGION` env var

Open gitfool opened this issue 3 months ago • 2 comments

Output of aws-sso version:

AWS SSO CLI Version 2.1.0 -- Copyright 2021-2025 Aaron Turner
Homebrew (2.1.0) built at 2025-09-03T16:29:13Z

Describe the bug: Running aws-sso-profile, which is backed by aws-sso eval -p, before running some dotnet integration tests, which subsequently fail because the AWS_REGION env var is not defined and only that env var is checked by the dotnet sdk.

According to https://github.com/aws/aws-sdk-net/issues/2589#issuecomment-2321922776 this is not planned and the reference to support by AWS SDKs and tools shows various expectations. For that reason I think aws-sso should set both AWS_REGION and AWS_DEFAULT_REGION so that it works for all sdks/tools.

To Reproduce:

aws-sso-profile dev:admin
aws s3 ls # succeeds due to searching for both env vars, falling back to `AWS_DEFAULT_REGION`
dotnet test ... # fails due to only searching for `AWS_REGION` env var, which is not defined

Expected behavior: All sdks/tools should work after running aws-sso-profile, without needing extra steps to set other env vars.

Desktop (please complete the following information):

  • OS: Windows 11 (WSL)
  • Version: 10.0.26100.6584

gitfool avatar Sep 10 '25 23:09 gitfool

you've explained the desired outcome, but not how it should be chosen. Use the same value as DefaultRegion in the config.yaml or another option? What about backwards compatibility across all other SDK's? Does this need to be feature flagged?

synfinatic avatar Sep 11 '25 00:09 synfinatic

Yeah I was thinking the easiest way forward, at least initially, would be to use the same value as DefaultRegion. This could be gated by another new config option.

Looking further ahead, with room to make a breaking change, DefaultRegion is now a misnomer and should probably be renamed to just Region and which would set both variables without a feature gate, since it seems that both names only exist due to historical legacy, specifically for the aws cli v1. See AWS CLI supported environment variables:

AWS_DEFAULT_REGION ... This setting is for the AWS CLI only, and is kept for backwards compatibility. It is suggested to use the AWS SDK compatible AWS_REGION environment variable instead.

gitfool avatar Sep 11 '25 01:09 gitfool