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

aws/endpoints: Fix SDK resolving endpoint without region #420

Merged
merged 4 commits into from
Dec 12, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fixup pr feedback
  • Loading branch information
jasdel committed Dec 12, 2019
commit 96442158169bfec5854aa3f929406d66c9f6a963
2 changes: 1 addition & 1 deletion CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ SDK Enhancements
SDK Bugs
---
* `aws/endpoints`: aws/endpoints: Fix SDK resolving endpoint without region ([#420](https://github.com/aws/aws-sdk-go-v2/pull/420))
* Fixes the SDK's endpoint resolve incorrectly resolving endpoints for a service when the region is empty. Also fixes the SDK attempting to resolve a service when the service value is empty..
* Fixes the SDK's endpoint resolve incorrectly resolving endpoints for a service when the region is empty. Also fixes the SDK attempting to resolve a service when the service value is empty.
* Related to [aws/aws-sdk-go#2909](https://github.com/aws/aws-sdk-go/issues/2909)
14 changes: 7 additions & 7 deletions aws/endpoints/v3model.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func (p partition) canResolveEndpoint(service, region string, strictMatch bool)
return p.RegionRegex.MatchString(region)
}

func allowLegacyEmptyRegion(service string) bool {
legacy := map[string]struct{}{
"ec2metadata": {},
}
var allowEmptyRegion = map[string]struct{}{
"ec2metadata": {},
}

_, allowed := legacy[service]
return allowed
func serviceRequiresRegion(service string) bool {
_, allowed := allowEmptyRegion[service]
return !allowed
}

func (p partition) EndpointFor(service, region string, opts ResolveOptions) (resolved aws.Endpoint, err error) {
Expand All @@ -91,7 +91,7 @@ func (p partition) EndpointFor(service, region string, opts ResolveOptions) (res
return resolved, NewUnknownServiceError(p.ID, service, serviceList(p.Services))
}

if len(region) == 0 && allowLegacyEmptyRegion(service) && len(s.PartitionEndpoint) != 0 {
if len(region) == 0 && !serviceRequiresRegion(service) && len(s.PartitionEndpoint) != 0 {
region = s.PartitionEndpoint
}

Expand Down