Always pick us-east-1 for the "aws" partition (#8679)

* 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>
This commit is contained in:
Becca Petrin
2020-04-03 15:08:56 -07:00
committed by GitHub
parent 9c507670ff
commit d0f7531599
2 changed files with 13 additions and 1 deletions

View File

@@ -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
}

View File

@@ -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())
}
}