Skip to content

Commit

Permalink
Merge pull request kubernetes-sigs#210 from openshift-cherrypick-robo…
Browse files Browse the repository at this point in the history
…t/cherry-pick-209-to-release-4.10

[release-4.10] OCPBUGS-1804: UPSTREAM: 1398: Add resolver to handle custom endpoints
  • Loading branch information
openshift-merge-robot authored Sep 30, 2022
2 parents 8ba0c7a + fb821bd commit 2bad4b4
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/cloud/cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ec2"
Expand Down Expand Up @@ -240,7 +241,16 @@ func newEC2Cloud(region string, awsSdkDebugLog bool) (Cloud, error) {

endpoint := os.Getenv("AWS_EC2_ENDPOINT")
if endpoint != "" {
awsConfig.Endpoint = aws.String(endpoint)
customResolver := func(service, region string, optFns ...func(*endpoints.Options)) (endpoints.ResolvedEndpoint, error) {
if service == endpoints.Ec2ServiceID {
return endpoints.ResolvedEndpoint{
URL: endpoint,
SigningRegion: region,
}, nil
}
return endpoints.DefaultResolver().EndpointFor(service, region, optFns...)
}
awsConfig.EndpointResolver = endpoints.ResolverFunc(customResolver)
}

if awsSdkDebugLog {
Expand Down

0 comments on commit 2bad4b4

Please sign in to comment.