-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.go
More file actions
39 lines (37 loc) · 1.23 KB
/
util.go
File metadata and controls
39 lines (37 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package main
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go/aws/endpoints"
)
// Unfortunately there is no good way to resolve endpoints for a given service
// and region. We fallback to the v1 SDK to resolve endpoints.
func defaultEndpointResolver(partition string) aws.EndpointResolver {
var awsPartition endpoints.Partition
if partition == "aws" {
awsPartition = endpoints.AwsPartition()
} else if partition == "aws-cn" {
awsPartition = endpoints.AwsCnPartition()
} else if partition == "aws-gov" {
awsPartition = endpoints.AwsUsGovPartition()
} else if partition == "aws-iso" {
awsPartition = endpoints.AwsIsoPartition()
} else if partition == "aws-iso-b" {
awsPartition = endpoints.AwsIsoBPartition()
} else {
panic(fmt.Sprintf("Unknown partition: %s", partition))
}
return aws.EndpointResolverFunc(func(service, region string) (aws.Endpoint, error) {
endpoint, err := awsPartition.EndpointFor(service, region)
if err != nil {
return aws.Endpoint{}, err
}
return aws.Endpoint{
URL: endpoint.URL,
PartitionID: endpoint.PartitionID,
SigningName: endpoint.SigningName,
SigningRegion: endpoint.SigningRegion,
SigningMethod: endpoint.SigningMethod,
}, nil
})
}