fix(rds): properly handle RETAIN_ON_UPDATE_OR_DELETE in subresources - #38331
fix(rds): properly handle RETAIN_ON_UPDATE_OR_DELETE in subresources#38331wasim-builds wants to merge 6 commits into
Conversation
|
Exemption Request: Adding integration tests for RETAIN_ON_UPDATE_OR_DELETE subresources requires complex setup that is fully validated by unit tests. |
|
The max-len linter error has been fixed, and the missing integration test snapshots have been generated and pushed. |
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
| */ | ||
| export function defaultDeletionProtection(deletionProtection?: boolean, removalPolicy?: RemovalPolicy): boolean | undefined { | ||
| return deletionProtection ?? (removalPolicy === RemovalPolicy.RETAIN ? true : undefined); | ||
| return deletionProtection ?? (removalPolicy === RemovalPolicy.RETAIN || |
There was a problem hiding this comment.
What about declaring a global const retentionPolicies = [RemovalPolicy.RETAIN, RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE] and
return deletionProtection ?? (retentionPolicies.includes(removalPolicy) ? true : undefined);Similar for method below.
| export function helperRemovalPolicy(basePolicy?: RemovalPolicy): RemovalPolicy { | ||
| return basePolicy === RemovalPolicy.RETAIN | ||
| ? RemovalPolicy.RETAIN | ||
| return basePolicy === RemovalPolicy.RETAIN || basePolicy === RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE |
There was a problem hiding this comment.
Can you update the comments to both methods to reflect the new behavior?
| }); | ||
| }); | ||
|
|
||
| test("sets the retention policy of the SubnetGroup to 'Retain' if the Serverless Cluster is created with 'RetainOnUpdateOrDelete'", () => { |
There was a problem hiding this comment.
Can you add coverage for defaultDeletionProtection as well?
Fixes #37780
Problem
RdsInstance/ServerlessClustersubresources did not properly handleRemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE, causing incorrect behavior during stack updates.Fix
Update
helperRemovalPolicyanddefaultDeletionProtectionto pass throughRETAIN_ON_UPDATE_OR_DELETEinstead of collapsing it. Apply the fix toserverless-cluster.tsas well.Scope
packages/aws-cdk-lib/aws-rds/lib/private/util.ts: policy passthrough fixpackages/aws-cdk-lib/aws-rds/lib/serverless-cluster.ts: apply corrected policyVerification
Serverless cluster and RDS instances now preserve
RETAIN_ON_UPDATE_OR_DELETEsemantics during updates.