aws / aws/aws-cdk

cli: Getting "unsupported resource type Custom:AWSCDK-EKS-Cluster"

Open
#33,274 4 comments 1 reaction 0 assignees View on GitHub
bug effort/small p3 package/tools
Dominant language
TypeScript
Stars
12.9k
Forks
4.6k
Avg merge
2d 3h
Merged PRs (30d)
83

Description

### Describe the bug

I'm running the AWS CDK CLI

```
% cdk version
2.177.0 (build b396961)
```

And I'm trying to import an already existing EKS Cluster:

```
cdk import EksPrivateCluster
```

Here's how the resource is defined in AWS CDK using Java:

Cluster.Builder.create(this, "eks")
.vpc(Vpc.fromLookup(this,
"Vpc",
VpcLookupOptions.builder().vpcId("vpc-id").build()))
.version(KubernetesVersion.V1_29)
.vpcSubnets(List.of(SubnetSelection.builder().subnets(List.of(Subnet.fromSubnetId(this, "vpc-ns-eu-central-1b", "subnet1-id"), Subnet.fromSubnetId(this, "vpc-ns-eu-central-1a", "subnet2-id"))).build()))
.clusterName("test-cluster")
.defaultCapacity(0)
.outputClusterName(true)
.outputConfigCommand(true)
.outputMastersRoleArn(true)
.build();

Here's what I see in the logs:

```
% cdk import EksPrivateCluster
[Warning at /EksPrivateCluster/vpc-ns-eu-central-1b] No routeTableId was provided to the subnet 'subnet1-id'. Attempting to read its .routeTable.routeTableId will return null/undefined. (More info: https://github.com/aws/aws-cdk/pull/3171) [ack: @aws-cdk/aws-ec2:noSubnetRouteTableId]
[Warning at /EksPrivateCluster/vpc-ns-eu-central-1a] No routeTableId was provided to the subnet 'subnet2-id'. Attempting to read its .routeTable.routeTableId will return null/undefined. (More info: https://github.com/aws/aws-cdk/pull/3171) [ack: @aws-cdk/aws-ec2:noSubnetRouteTableId]
[Warning at /EksPrivateCluster/eks] You created a cluster with Kubernetes Version 1.29 without specifying the kubectlLayer property. The property will become required instead of optional in 2025 Jan. Please update your CDK code to provide a kubectlLayer. [ack: @aws-cdk/aws-eks:clusterKubectlLayerNotSpecified]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet3-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet2-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet4-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet5-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet6-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet7-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet8-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet1-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet9-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet10-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet11-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet12-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet13-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
[Warning at /EksPrivateCluster/eks] Could not auto-tag private subnet subnet14-id with "kubernetes.io/role/internal-elb=1", please remember to do this manually [ack: @aws-cdk/aws-eks:clusterMustManuallyTagSubnet]
EksPrivateCluster
start: Building 936b441cc12cd5d931778a2b30a87745db2a84f7df36039590183498dbe59c99:-eu-central-1
success: Built 936b441cc12cd5d931778a2b30a87745db2a84f7df36039590183498dbe59c99:-eu-central-1
start: Publishing 936b441cc12cd5d931778a2b30a87745db2a84f7df36039590183498dbe59c99:-eu-central-1
success: Published 936b441cc12cd5d931778a2b30a87745db2a84f7df36039590183498dbe59c99:-eu-central-1
start: Building 5cf40520585ae27edc46116f4bc45682ce419f4fac601da1e05b600c25a2bf8f:-eu-central-1
success: Built 5cf40520585ae27edc46116f4bc45682ce419f4fac601da1e05b600c25a2bf8f:-eu-central-1
start: Publishing 5cf40520585ae27edc46116f4bc45682ce419f4fac601da1e05b600c25a2bf8f:-eu-central-1
success: Published 5cf40520585ae27edc46116f4bc45682ce419f4fac601da1e05b600c25a2bf8f:-eu-central-1
start: Building c7303c77fc646601409777ef856517e3143b38c53b48f596972388ec414ce29a:-eu-central-1
success: Built c7303c77fc646601409777ef856517e3143b38c53b48f596972388ec414ce29a:-eu-central-1
start: Publishing c7303c77fc646601409777ef856517e3143b38c53b48f596972388ec414ce29a:-eu-central-1
success: Published c7303c77fc646601409777ef856517e3143b38c53b48f596972388ec414ce29a:-eu-central-1
EksPrivateCluster/eks/KubectlHandlerRole/Resource (AWS::IAM::Role): enter RoleName (empty to skip):
Skipping import of EksPrivateCluster/eks/KubectlHandlerRole/Resource
EksPrivateCluster/eks/KubectlHandlerRole/DefaultPolicy/Resource (AWS::IAM::Policy): enter Id (empty to skip):
Skipping import of EksPrivateCluster/eks/KubectlHandlerRole/DefaultPolicy/Resource
EksPrivateCluster/eks/Role/Resource (AWS::IAM::Role): enter RoleName (empty to skip):
Skipping import of EksPrivateCluster/eks/Role/Resource
EksPrivateCluster/eks/ControlPlaneSecurityGroup/Resource (AWS::EC2::SecurityGroup): enter Id (empty to skip):
Skipping import of EksPrivateCluster/eks/ControlPlaneSecurityGroup/Resource
EksPrivateCluster/eks/Resource/CreationRole/Resource (AWS::IAM::Role): enter RoleName (empty to skip):
Skipping import of EksPrivateCluster/eks/Resource/CreationRole/Resource
EksPrivateCluster/eks/Resource/CreationRole/DefaultPolicy/Resource (AWS::IAM::Policy): enter Id (empty to skip):
Skipping import of EksPrivateCluster/eks/Resource/CreationRole/DefaultPolicy/Resource
EksPrivateCluster/eks/Resource/Resource/Default: unsupported resource type Custom::AWSCDK-EKS-Cluster, skipping import.
EksPrivateCluster/eks/KubectlReadyBarrier (AWS::SSM::Parameter): enter Name (empty to skip):
Skipping import of EksPrivateCluster/eks/KubectlReadyBarrier
EksPrivateCluster/@aws-cdk--aws-eks.ClusterResourceProvider.NestedStack/@aws-cdk--aws-eks.ClusterResourceProvider.NestedStackResource (AWS::CloudFormation::Stack): enter StackId (empty to skip):
Skipping import of EksPrivateCluster/@aws-cdk--aws-eks.ClusterResourceProvider.NestedStack/@aws-cdk--aws-eks.ClusterResourceProvider.NestedStackResource
EksPrivateCluster/@aws-cdk--aws-eks.KubectlProvider.NestedStack/@aws-cdk--aws-eks.KubectlProvider.NestedStackResource (AWS::CloudFormation::Stack): enter StackId (empty to skip):
Skipping import of EksPrivateCluster/@aws-cdk--aws-eks.KubectlProvider.NestedStack/@aws-cdk--aws-eks.KubectlProvider.NestedStackResource
No resources selected for import.
```

Notice the line that says `EksPrivateCluster/eks/Resource/Resource/Default: unsupported resource type Custom::AWSCDK-EKS-Cluster, skipping import.`, and also the bottom line: `No resources selected for import.`. Are EKS Clusters simply not supported for import yet or is this a bug?´

### Regression Issue

- [ ] Select this option if this issue appears to be a regression.

### Last Known Working CDK Version

_No response_

### Expected Behavior

I expected to be able to import my EKS cluster into CloudFormation.

### Current Behavior

Cluster is not imported.

### Reproduction Steps

**PrivateClusterCdkApp:**

```
package com.amazonaws.cdk.examples;

import software.amazon.awscdk.App;
import software.amazon.awscdk.Environment;
import software.amazon.awscdk.StackProps;

public class PrivateClusterCdkApp {
public static void main(final String[] args) {
App app = new App();
StackProps stackProps = StackProps.builder()
.env(Environment.builder()
.account("fill out with your acc")
.region("fill out with your region")
.build()).build();
new EksPrivateClusterStack(app, "EksPrivateCluster", stackProps);

app.synth();
}
}
```

**EksPrivateClusterStack:**

```
package com.amazonaws.cdk.examples;

import software.amazon.awscdk.Stack;
import software.amazon.awscdk.StackProps;
import software.amazon.awscdk.services.ec2.Subnet;
import software.amazon.awscdk.services.ec2.SubnetSelection;
import software.amazon.awscdk.services.ec2.Vpc;
import software.amazon.awscdk.services.ec2.VpcLookupOptions;
import software.amazon.awscdk.services.eks.Cluster;
import software.amazon.awscdk.services.eks.KubernetesVersion;
import software.constructs.Construct;

import java.util.List;

/**
* Builds a private EKS cluster in isolated subnets with no Internet or NAT gateways attached.
*
*


*/
public class EksPrivateClusterStack extends Stack {
private Cluster cluster;

public EksPrivateClusterStack(final Construct scope, final String id) {
this(scope, id, null);
}

public EksPrivateClusterStack(final Construct scope, final String id, final StackProps props) {
super(scope, id, props);

createEksCluster();
}

private void createEksCluster() {
this.cluster =
Cluster.Builder.create(this, "eks")
.vpc(Vpc.fromLookup(this,
"Vpc",
VpcLookupOptions.builder().vpcId("vpc-id").build()))
.version(KubernetesVersion.V1_29)
.vpcSubnets(List.of(SubnetSelection.builder().subnets(List.of(Subnet.fromSubnetId(this, "vpc-ns-eu-central-1b", "subnet1-id"), Subnet.fromSubnetId(this, "vpc-ns-eu-central-1a", "subnet2-id"))).build())) // Give your subnets.
.clusterName("cluster name") // Fill out with your own cluster name
.defaultCapacity(0)
.outputClusterName(true)
.outputConfigCommand(true)
.outputMastersRoleArn(true)
.build();
}

public Cluster getCluster() {
return this.cluster;
}
}
```

Run import with: `cdk import EksPrivateCluster`

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### CDK CLI Version

2.177.0

### Framework Version

_No response_

### Node.js Version

v22.2.0

### OS

Sonoma 14.5

### Language

Java

### Language Version

openjdk 17.0.12

### Other information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the `cdk import EksPrivateCluster` entry point and the Java `Cluster` construct in the reproduction, then trace how the `Custom::AWSCDK-EKS-Cluster` resource is handled during import. Determine whether EKS cluster resources are supported, identify the relevant import behavior or documentation, and define completion as either a working import path with coverage or a clear documented limitation.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, java
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.