Skip to content

[aws-eks] Cannot call applyRemovalPolicy on KubernetesManifest objects #9921

@mifisignal

Description

@mifisignal

In an attempt to prevent a Kubernetes resource from being deleted during stack destruction, I tried to use the current tribal-knowledge method:

      const meshResource = cluster.addManifest(`Mesh${clusterName}`, {
        apiVersion: "appmesh.k8s.aws/v1beta2",
        kind: "Mesh",
        metadata: {
          name: "mesh",
        },
        spec: {
          awsName: mesh.meshName,
          namespaceSelector: {
            matchLabels: {
              mesh: mesh.meshName,
            },
          },
        },
      });
      meshResource.node.addDependency(mesh, appMeshController);
      (meshResource.node.defaultChild as cdk.CfnResource).applyRemovalPolicy(cdk.RemovalPolicy.RETAIN);

This did not work:

$ npm run cdk synth       
...
meshResource.node.defaultChild.applyRemovalPolicy is not a function
Subprocess exited with error 1

Environment

  • CLI Version : 1.60.0
  • Framework Version: 1.60.0
  • Node.js Version: 12.18.2
  • OS : MacOS Catalina
  • Language (Version): TypeScript

This is 🐛 Bug Report

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-eksRelated to Amazon Elastic Kubernetes ServicebugThis issue is a bug.effort/smallSmall work item – less than a day of effortp1

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions