Skip to content

(aws-eks-v2-alpha): kubectl-based resources may not be successfully created/deleted #34897

Open
@msessa

Description

@msessa

Describe the bug

When creating/deleting resources that rely on the kubectl provider (eg. HelmChart, KubernetesManifest) it is possible that the AccessEntry for the kubectl provider could not yet have been created or, in case of a stack deletion, have been deleted before those resources, leaving kubectl without the appropriate permissions.

Regression Issue

  • Select this option if this issue appears to be a regression.

Last Known Working CDK Library Version

No response

Expected Behavior

The AccessEntry for the kubectl provider should be included in the KubectlReadyBarrier's dependencies to ensure correct ordering when creating/deleting resources

Current Behavior

The AccessEntry for the kubectl is not explicitly marked as a dependency of the KubectlReadyBarrier resource. Opening the possibility of incorrect order of operation especially during delete.

As an example, these are the CR handler logs of a HelmChart being deleted, which happens after the AccessEntry has already been deleted:

[INFO]	2025-07-03T02:32:51.662Z	f0b1956e-0a0b-4a00-b917-020cff7feb80	{
    "RequestType": "Delete",
    "ServiceToken": "...",
    "ResponseURL": "...",
    "StackId": "...",
    "RequestId": "3585eea3-9049-4f93-9f87-287315d7e681",
    "LogicalResourceId": "SolrZooKeeperChart41F0FD45",
    "PhysicalResourceId": "...",
    "ResourceType": "Custom::AWSCDK-EKS-HelmChart",
    "ResourceProperties": {
        "ServiceToken": "...",
        "Values": "...",
        "ClusterName": "SolrCluster46192153-kKOPdVgcdKuy",
        "Wait": "true",
        "Release": "zookeeper",
        "Chart": "oci://registry-1.docker.io/bitnamicharts/zookeeper",
        "Namespace": "default"
    }
}
Updated context arn:aws:eks:ap-southeast-2:...:cluster/SolrCluster46192153-kKOPdVgcdKuy in /tmp/kubeconfig
[INFO]	2025-07-03T02:32:54.747Z	f0b1956e-0a0b-4a00-b917-020cff7feb80	delete error: b'Error: Kubernetes cluster unreachable: the server has asked for the client to provide credentials\n'

Reproduction Steps

  • Create a cluster with kubectl support, and at least one HelmChart or KubernetesManifest resource
  • Delete the stack

observe the AccessEntry for kubectl provider being immediately deleted. observe errors in deleting the HelmChart or KubernetesManifest within the logs of the kubectl handler

Possible Solution

No response

Additional Information/Context

No response

AWS CDK Library version (aws-cdk-lib)

2.203.0

AWS CDK CLI version

latest

Node.js Version

20

OS

Mac

Language

TypeScript

Language Version

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/custom-resourcesRelated to AWS CDK Custom ResourcesbugThis issue is a bug.effort/mediumMedium work item – several days of effortp2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions