Skip to content

Commit

Permalink
fix(aws): override default region if AWS_REGION is set
Browse files Browse the repository at this point in the history
Co-authored-by: Evgenii Morozov <emorozov@goodgamestudios.com>
  • Loading branch information
ttyz and evmoroz committed Aug 4, 2021
1 parent f83fb24 commit 84183b7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/segment_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (a *aws) enabled() bool {
if !displayDefaultUser && a.Profile == defaultUser {
return false
}
a.Region = getEnvFirstMatch("AWS_DEFAULT_REGION", "AWS_REGION")
a.Region = getEnvFirstMatch("AWS_REGION", "AWS_DEFAULT_REGION")
if a.Profile != "" && a.Region != "" {
return true
}
Expand Down
3 changes: 2 additions & 1 deletion src/segment_aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ func TestAWSSegment(t *testing.T) {
{Case: "enabled with default user", ExpectedString: "default@eu-west", Profile: "default", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true},
{Case: "disabled with default user", ExpectedString: "default", Profile: "default", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false},
{Case: "enabled no region", ExpectedString: "company", ExpectedEnabled: true, Profile: "company"},
{Case: "enabled with region", ExpectedString: "company@eu-west", ExpectedEnabled: true, Profile: "company", Region: "eu-west"},
{Case: "enabled with region", ExpectedString: "company@eu-west", ExpectedEnabled: true, Profile: "company", Region: "eu-west", DefaultRegion: "us-west"},
{Case: "enabled with default region", ExpectedString: "company@us-west", ExpectedEnabled: true, Profile: "company", DefaultRegion: "us-west"},
{
Case: "template: enabled no region",
ExpectedString: "profile: company",
Expand Down

0 comments on commit 84183b7

Please sign in to comment.