Skip to content

Commit 882a39e

Browse files
tyrannosaurus-becksJim Kalafut
andauthored
Always pick us-east-1 for the "aws" partition (#8679) (#8680)
* always pick us-east-1 for aws partition * Update builtin/credential/aws/backend.go Co-Authored-By: Jim Kalafut <[email protected]> Co-authored-by: Jim Kalafut <[email protected]> Co-authored-by: Jim Kalafut <[email protected]>
1 parent c8752b0 commit 882a39e

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

builtin/credential/aws/backend.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,13 @@ func generatePartitionToRegionMap() map[string]*endpoints.Region {
307307
partitions := resolver.(endpoints.EnumPartitions).Partitions()
308308

309309
for _, p := range partitions {
310-
// Choose a single region randomly from the partition
310+
// For most partitions, it's fine to choose a single region randomly.
311+
// However, for the "aws" partition, it's best to choose "us-east-1"
312+
// because it is always enabled (and enabled for STS) by default.
311313
for _, r := range p.Regions() {
314+
if p.ID() == "aws" && r.ID() != "us-east-1" {
315+
continue
316+
}
312317
partitionToRegion[p.ID()] = &r
313318
break
314319
}

builtin/credential/aws/backend_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,3 +1813,10 @@ func generateRenewRequest(s logical.Storage, auth *logical.Auth) *logical.Reques
18131813

18141814
return renewReq
18151815
}
1816+
1817+
func TestGeneratePartitionToRegionMap(t *testing.T) {
1818+
m := generatePartitionToRegionMap()
1819+
if m["aws"].ID() != "us-east-1" {
1820+
t.Fatal("expected us-east-1 but received " + m["aws"].ID())
1821+
}
1822+
}

0 commit comments

Comments
 (0)