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

Use partition prefix for VPC endpoint services #2576

Merged
merged 2 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions pkg/apis/eksctl.io/v1alpha5/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"

Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion pkg/cfn/builder/vpc_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down