Skip to content

Commit 4b4e322

Browse files
authored
feat(eks): add removal policy support for EKS cluster construct (#35560)
### Issue # (if applicable) Closes #25544 ### Reason for this change Added the `removalPolicy` prop to the EKS cluster. This will apply the removal policy to all resources created by the cluster including node groups, roles, vpc and security groups. This also includes the custom resource that created the construct. Currently this is possible with `RemovalPolicies.of(cluster).apply` but this is not a user friendly API, this PR just abstracts that with a `removalPolicy` prop which is the expected behavior when using L2s. ### Description of changes Added `removalPolicy` property to the `ClusterProps` interface in the EKS library that allows users to specify a removal policy for all CloudFormation resources created by the EKS cluster construct. - Added `readonly removalPolicy?: RemovalPolicy` to `ClusterProps` interface - Added integration test `integ.eks-cluster-retain.ts` to verify removal policy functionality with `RemovalPolicy.DESTROY`. If it deploys with destroy, it will also deploy with retain. The reason we don't write a specific retain integ test is that it will orphan resources in the account for anyone who deploys the integ test. The removal policy affects the EKS cluster itself, associated IAM roles, node groups, security groups, VPC resources, and any other CloudFormation resources managed by this construct. ### Describe any new or updated permissions being added No new IAM permissions are required for this change. ### Description of how you validated changes - Added integration test `integ.eks-cluster-retain.ts` that creates an EKS cluster with `RemovalPolicy.RETAIN` - The test verifies that all resources can be deployed successfully with the removal policy applied, and the snapshot validates we added the policy to all resources. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 8a6cf46 commit 4b4e322

30 files changed

+7135
-1
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-eks/test/integ.eks-cluster-removal-policy.js.snapshot/EksClusterRemovalPolicyStack.assets.json

Lines changed: 146 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)