Skip to content

Fix set AWS_REGION alongside AWS_DEFAULT_REGION#1370

Merged
synfinatic merged 1 commit into
synfinatic:mainfrom
gitfool:fix-aws-region
May 21, 2026
Merged

Fix set AWS_REGION alongside AWS_DEFAULT_REGION#1370
synfinatic merged 1 commit into
synfinatic:mainfrom
gitfool:fix-aws-region

Conversation

@gitfool
Copy link
Copy Markdown
Contributor

@gitfool gitfool commented May 20, 2026

Problem

PR #1336 was supposed to fix #1277 by managing $AWS_REGION alongside
$AWS_DEFAULT_REGION, but the fix was incomplete. The unset path
(eval --clear) and the guard in GetDefaultRegion were both updated to
handle $AWS_REGION, and the docs were updated to say both variables are
managed — but execShellEnvs (the function that actually sets env vars for
eval/exec/aws-sso-profile) was never updated to include AWS_REGION.

Reproduction:

aws-sso-profile dev:admin
printenv | grep AWS_REGION   # empty — only AWS_DEFAULT_REGION is set
dotnet test ...               # fails — .NET SDK only reads AWS_REGION

Changes

cmd/aws-sso/exec_cmd.go

  • Extracted the region-assignment block from execShellEnvs into a new
    setRegionVars(shellVars map[string]string, region string) helper.
  • setRegionVars now sets AWS_REGION alongside AWS_DEFAULT_REGION and
    AWS_SSO_DEFAULT_REGION when a region is configured.
  • Updated the --no-region / -n flag help text to mention AWS_REGION.

cmd/aws-sso/exec_cmd_test.go (new file)

  • Added TestSetRegionVars covering both cases:
    • non-empty region → all three vars (AWS_DEFAULT_REGION, AWS_REGION,
      AWS_SSO_DEFAULT_REGION) are set to the configured value
    • empty region → only the sentinel AWS_SSO_DEFAULT_REGION is cleared

No other changes required

Component Status
Unset on eval --clear (eval_cmd.go) ✅ already unsets AWS_REGION
Don't override user-set region (settings.go) ✅ already reads AWS_REGION as fallback
Docs (FAQ.md, config.md) ✅ already describe both vars being managed

@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.52%. Comparing base (cf7edfa) to head (c6c18cd).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1370   +/-   ##
=======================================
  Coverage   88.52%   88.52%           
=======================================
  Files          54       54           
  Lines        3649     3649           
=======================================
  Hits         3230     3230           
  Misses        289      289           
  Partials      130      130           
Flag Coverage Δ
unittests 88.52% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cf7edfa...c6c18cd. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@synfinatic
Copy link
Copy Markdown
Owner

Thank you @gitfool !

@synfinatic synfinatic merged commit 5e126c1 into synfinatic:main May 21, 2026
9 checks passed
@gitfool gitfool deleted the fix-aws-region branch May 21, 2026 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

aws-sso eval should set/unset AWS_REGION env var

2 participants