diff --git a/src/segment_aws.go b/src/segment_aws.go index c5e59b33..d3f4024e 100644 --- a/src/segment_aws.go +++ b/src/segment_aws.go @@ -40,7 +40,7 @@ func (a *aws) enabled() bool { if a.Profile != "" && a.Region != "" { return true } - if a.Profile == "" && a.Region != "" { + if a.Profile == "" && a.Region != "" && displayDefaultUser { a.Profile = defaultUser return true } diff --git a/src/segment_aws_test.go b/src/segment_aws_test.go index e5781b69..cffb43ff 100644 --- a/src/segment_aws_test.go +++ b/src/segment_aws_test.go @@ -19,6 +19,8 @@ func TestAWSSegment(t *testing.T) { Template string DisplayDefault bool }{ + {Case: "enabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: true, DisplayDefault: true}, + {Case: "disabled with default user", ExpectedString: "default@eu-west", Region: "eu-west", ExpectedEnabled: false, DisplayDefault: false}, {Case: "disabled", ExpectedString: "", ExpectedEnabled: false}, {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},