-
Notifications
You must be signed in to change notification settings - Fork 4.5k
eks: ack prop for potential cluster replacement #30107
Description
Describe the feature
aws-eks.Cluster has some cluster props that would result in cluster replacement on prop update.
aws-cdk/packages/@aws-cdk/custom-resource-handlers/lib/aws-eks/cluster-resource-handler/cluster.ts
Lines 116 to 130 in 3928eae
| // if there is an update that requires replacement, go ahead and just create | |
| // a new cluster with the new config. The old cluster will automatically be | |
| // deleted by cloudformation upon success. | |
| if (updates.replaceName || updates.replaceRole || updates.replaceVpc) { | |
| // if we are replacing this cluster and the cluster has an explicit | |
| // physical name, the creation of the new cluster will fail with "there is | |
| // already a cluster with that name". this is a common behavior for | |
| // CloudFormation resources that support specifying a physical name. | |
| if (this.oldProps.name === this.newProps.name && this.oldProps.name) { | |
| throw new Error(`Cannot replace cluster "${this.oldProps.name}" since it has an explicit physical name. Either rename the cluster or remove the "name" configuration`); | |
| } | |
| return this.onCreate(); | |
| } |
And users can hardly tell that from cdk diff or cdk deploy as the cluster resource is actually a custom resource and we just notice the custom resource props change in this case.
We only notice that the custom resource would change but in fact the existing cluster would be torn down and replaced, resulting data loss.
I think we should have a gatekeeper prop which default value is false and only when you explicit set it as true will the cluster replacement happen.
Use Case
as above
Proposed Solution
I was thinking maybe we can have a removalPolicy prop of the cluster which default to RETAIN and the cluster replacement would only happen when the value is DESTROY
Another option is to have a replaceOnUpdate or allowReplaceOnUpdate prop for eks.Cluster which defaults to false.
Other Information
No response
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
CDK version used
all
Environment details (OS name and version, etc.)
all