Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use us-gov-west-1 for global APIs in aws-us-gov #9947

Merged
merged 4 commits into from
Sep 26, 2020
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
13 changes: 11 additions & 2 deletions builtin/credential/aws/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,21 @@ func generatePartitionToRegionMap() map[string]*endpoints.Region {

for _, p := range partitions {
// 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.
// However, there are a few exceptions:
//
// For "aws", choose "us-east-1" because it is always enabled (and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really appreciate the extended comments in here!

// enabled for STS) by default.
//
// For "aws-us-gov", choose "us-gov-west-1" because it is the only
// valid region for IAM operations.
// ref: https://github.com/aws/aws-sdk-go/blob/v1.34.25/aws/endpoints/defaults.go#L8176-L8194
for _, r := range p.Regions() {
if p.ID() == "aws" && r.ID() != "us-east-1" {
continue
}
if p.ID() == "aws-us-gov" && r.ID() != "us-gov-west-1" {
continue
}
partitionToRegion[p.ID()] = &r
break
}
Expand Down
3 changes: 3 additions & 0 deletions builtin/credential/aws/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1819,4 +1819,7 @@ func TestGeneratePartitionToRegionMap(t *testing.T) {
if m["aws"].ID() != "us-east-1" {
t.Fatal("expected us-east-1 but received " + m["aws"].ID())
}
if m["aws-us-gov"].ID() != "us-gov-west-1" {
t.Fatal("expected us-gov-west-1 but received " + m["aws-us-gov"].ID())
}
}