diff --git a/pkg/eks/api.go b/pkg/eks/api.go index 87406a3ea5..bf32161f9c 100644 --- a/pkg/eks/api.go +++ b/pkg/eks/api.go @@ -203,7 +203,11 @@ func newAWSProvider(spec *api.ProviderConfig, configurationLoader AWSConfigurati provider.asg = autoscaling.NewFromConfig(cfg) provider.cloudwatchlogs = cloudwatchlogs.NewFromConfig(cfg) provider.cloudtrail = cloudtrail.NewFromConfig(cfg, func(o *cloudtrail.Options) { - o.BaseEndpoint = getBaseEndpoint(cloudtrail.ServiceID, "AWS_CLOUDTRAIL_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(cloudtrail.ServiceID, []string{ + "AWS_CLOUDTRAIL_ENDPOINT", + "AWS_ENDPOINT_URL_CLOUDTRAIL", + "AWS_ENDPOINT_URL", + }) }) return provider, nil diff --git a/pkg/eks/services_v2.go b/pkg/eks/services_v2.go index 573a75417f..bc0d69178c 100644 --- a/pkg/eks/services_v2.go +++ b/pkg/eks/services_v2.go @@ -48,7 +48,11 @@ func (s *ServicesV2) STS() awsapi.STS { defer s.mu.Unlock() if s.sts == nil { s.sts = sts.NewFromConfig(s.config, func(o *sts.Options) { - o.BaseEndpoint = getBaseEndpoint(sts.ServiceID, "AWS_STS_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(sts.ServiceID, []string{ + "AWS_STS_ENDPOINT", + "AWS_ENDPOINT_URL_STS", + "AWS_ENDPOINT_URL", + }) // Disable retryer for STS // (see https://github.com/eksctl-io/eksctl/issues/705) o.Retryer = aws.NopRetryer{} @@ -79,7 +83,11 @@ func (s *ServicesV2) CloudFormation() awsapi.CloudFormation { defer s.mu.Unlock() if s.cloudformation == nil { s.cloudformation = cloudformation.NewFromConfig(s.config, func(o *cloudformation.Options) { - o.BaseEndpoint = getBaseEndpoint(cloudformation.ServiceID, "AWS_CLOUDFORMATION_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(cloudformation.ServiceID, []string{ + "AWS_CLOUDFORMATION_ENDPOINT", + "AWS_ENDPOINT_URL_CLOUDFORMATION", + "AWS_ENDPOINT_URL", + }) // Use adaptive mode for retrying CloudFormation requests to mimic // the logic used for AWS SDK v1. o.Retryer = retry.NewAdaptiveMode(func(o *retry.AdaptiveModeOptions) { @@ -101,7 +109,11 @@ func (s *ServicesV2) ELB() awsapi.ELB { defer s.mu.Unlock() if s.elasticloadbalancing == nil { s.elasticloadbalancing = elasticloadbalancing.NewFromConfig(s.config, func(o *elasticloadbalancing.Options) { - o.BaseEndpoint = getBaseEndpoint(elasticloadbalancing.ServiceID, "AWS_ELB_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(elasticloadbalancing.ServiceID, []string{ + "AWS_ELB_ENDPOINT", + "AWS_ENDPOINT_URL_ELASTIC_LOAD_BALANCING", + "AWS_ENDPOINT_URL", + }) }) } return s.elasticloadbalancing @@ -113,7 +125,11 @@ func (s *ServicesV2) ELBV2() awsapi.ELBV2 { defer s.mu.Unlock() if s.elasticloadbalancingV2 == nil { s.elasticloadbalancingV2 = elasticloadbalancingv2.NewFromConfig(s.config, func(o *elasticloadbalancingv2.Options) { - o.BaseEndpoint = getBaseEndpoint(elasticloadbalancingv2.ServiceID, "AWS_ELBV2_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(elasticloadbalancingv2.ServiceID, []string{ + "AWS_ELBV2_ENDPOINT", + "AWS_ENDPOINT_URL_ELASTIC_LOAD_BALANCING_V2", + "AWS_ENDPOINT_URL", + }) }) } return s.elasticloadbalancingV2 @@ -135,7 +151,11 @@ func (s *ServicesV2) IAM() awsapi.IAM { defer s.mu.Unlock() if s.iam == nil { s.iam = iam.NewFromConfig(s.config, func(o *iam.Options) { - o.BaseEndpoint = getBaseEndpoint(iam.ServiceID, "AWS_IAM_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(iam.ServiceID, []string{ + "AWS_IAM_ENDPOINT", + "AWS_ENDPOINT_URL_IAM", + "AWS_ENDPOINT_URL", + }) }) } return s.iam @@ -147,7 +167,11 @@ func (s *ServicesV2) EC2() awsapi.EC2 { defer s.mu.Unlock() if s.ec2 == nil { s.ec2 = ec2.NewFromConfig(s.config, func(o *ec2.Options) { - o.BaseEndpoint = getBaseEndpoint(ec2.ServiceID, "AWS_EC2_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(ec2.ServiceID, []string{ + "AWS_EC2_ENDPOINT", + "AWS_ENDPOINT_URL_EC2", + "AWS_ENDPOINT_URL", + }) }) } return s.ec2 @@ -159,7 +183,11 @@ func (s *ServicesV2) EKS() awsapi.EKS { defer s.mu.Unlock() if s.eks == nil { s.eks = eks.NewFromConfig(s.config, func(o *eks.Options) { - o.BaseEndpoint = getBaseEndpoint(eks.ServiceID, "AWS_EKS_ENDPOINT") + o.BaseEndpoint = getBaseEndpoint(eks.ServiceID, []string{ + "AWS_EKS_ENDPOINT", + "AWS_ENDPOINT_URL_EC2", + "AWS_ENDPOINT_URL", + }) }) } return s.eks @@ -183,11 +211,12 @@ func (s *ServicesV2) CredentialsProvider() aws.CredentialsProvider { return s.config.Credentials } -func getBaseEndpoint(serviceID, endpoint string) *string { - if endpoint, ok := os.LookupEnv(endpoint); ok { - logger.Debug( - "Setting %s endpoint to %s", serviceID, endpoint) - return aws.String(endpoint) +func getBaseEndpoint(serviceID string, endpoints []string) *string { + for _, endpoint := range endpoints { + if value, ok := os.LookupEnv(endpoint); ok { + logger.Debug("Setting %s endpoint to %s", serviceID, value) + return aws.String(value) + } } return nil }