Skip to content

Commit

Permalink
Always pick us-east-1 for the "aws" partition (#8679) (#8680)
Browse files Browse the repository at this point in the history
* always pick us-east-1 for aws partition

* Update builtin/credential/aws/backend.go

Co-Authored-By: Jim Kalafut <jkalafut@hashicorp.com>

Co-authored-by: Jim Kalafut <jkalafut@hashicorp.com>

Co-authored-by: Jim Kalafut <jkalafut@hashicorp.com>
  • Loading branch information
tyrannosaurus-becks and Jim Kalafut committed Apr 9, 2020
1 parent c8752b0 commit 882a39e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion builtin/credential/aws/backend.go
Expand Up @@ -307,8 +307,13 @@ func generatePartitionToRegionMap() map[string]*endpoints.Region {
partitions := resolver.(endpoints.EnumPartitions).Partitions()

for _, p := range partitions {
// Choose a single region randomly from the partition
// For most partitions, it's fine to choose a single region randomly.
// However, for the "aws" partition, it's best to choose "us-east-1"
// because it is always enabled (and enabled for STS) by default.
for _, r := range p.Regions() {
if p.ID() == "aws" && r.ID() != "us-east-1" {
continue
}
partitionToRegion[p.ID()] = &r
break
}
Expand Down
7 changes: 7 additions & 0 deletions builtin/credential/aws/backend_test.go
Expand Up @@ -1813,3 +1813,10 @@ func generateRenewRequest(s logical.Storage, auth *logical.Auth) *logical.Reques

return renewReq
}

func TestGeneratePartitionToRegionMap(t *testing.T) {
m := generatePartitionToRegionMap()
if m["aws"].ID() != "us-east-1" {
t.Fatal("expected us-east-1 but received " + m["aws"].ID())
}
}

0 comments on commit 882a39e

Please sign in to comment.