Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion builtin/credential/aws/backend.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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())
}
}