diff --git a/pkg/apis/eksctl.io/v1alpha5/types.go b/pkg/apis/eksctl.io/v1alpha5/types.go index fa1630aa81..875341c065 100644 --- a/pkg/apis/eksctl.io/v1alpha5/types.go +++ b/pkg/apis/eksctl.io/v1alpha5/types.go @@ -59,7 +59,10 @@ const ( const ( // AWSDebugLevel defines the LogLevel for AWS produced logs AWSDebugLevel = 5 +) +// Regions +const ( // RegionUSWest1 represents the US West Region North California RegionUSWest1 = "us-west-1" @@ -134,7 +137,16 @@ const ( // DefaultRegion defines the default region, where to deploy the EKS cluster DefaultRegion = RegionUSWest2 +) + +// Partitions +const ( + PartitionAWS = "aws" + PartitionChina = "aws-cn" + PartitionUSGov = "aws-us-gov" +) +const ( // DefaultNodeType is the default instance type to use for nodes DefaultNodeType = "m5.large" @@ -319,6 +331,18 @@ func SupportedRegions() []string { } } +// Partition gives the partition a region belongs to +func Partition(region string) string { + switch region { + case RegionUSGovWest1, RegionUSGovEast1: + return PartitionUSGov + case RegionCNNorth1, RegionCNNorthwest1: + return PartitionChina + default: + return PartitionAWS + } +} + // DeprecatedVersions are the versions of Kubernetes that EKS used to support // but no longer does. See also: // https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html diff --git a/pkg/cfn/builder/vpc_endpoint.go b/pkg/cfn/builder/vpc_endpoint.go index a11e7ac767..7f7a1519c2 100644 --- a/pkg/cfn/builder/vpc_endpoint.go +++ b/pkg/cfn/builder/vpc_endpoint.go @@ -126,7 +126,11 @@ func (e *VPCEndpointResourceSet) hasEndpoint(endpoint string) bool { // BuildVPCEndpointServices builds a slice of VPCEndpointServiceDetails for the specified endpoint names func BuildVPCEndpointServices(ec2API ec2iface.EC2API, region string, endpoints []string) ([]VPCEndpointServiceDetails, error) { serviceNames := make([]string, len(endpoints)) - serviceRegionPrefix := fmt.Sprintf("com.amazonaws.%s.", region) + servicePrefix := "" + if api.Partition(region) == api.PartitionChina { + servicePrefix = "cn." + } + serviceRegionPrefix := fmt.Sprintf("%scom.amazonaws.%s.", servicePrefix, region) for i, endpoint := range endpoints { serviceNames[i] = serviceRegionPrefix + endpoint }