Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/aws-cdk-lib/aws-rds/lib/private/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function engineDescription(engine: IEngine) {
* Enable if explicitly provided or if the RemovalPolicy has been set to RETAIN
*/
export function defaultDeletionProtection(deletionProtection?: boolean, removalPolicy?: RemovalPolicy): boolean | undefined {
return deletionProtection ?? (removalPolicy === RemovalPolicy.RETAIN ? true : undefined);
return deletionProtection ?? (removalPolicy === RemovalPolicy.RETAIN || removalPolicy === RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE ? true : undefined);
}

/**
Expand Down Expand Up @@ -197,8 +197,8 @@ export function renderSnapshotCredentials(scope: Construct, credentials?: Snapsh
* (undefined) -> DESTROY (base policy is assumed to be SNAPSHOT)
*/
export function helperRemovalPolicy(basePolicy?: RemovalPolicy): RemovalPolicy {
return basePolicy === RemovalPolicy.RETAIN
? RemovalPolicy.RETAIN
return basePolicy === RemovalPolicy.RETAIN || basePolicy === RemovalPolicy.RETAIN_ON_UPDATE_OR_DELETE
? basePolicy
: RemovalPolicy.DESTROY;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk-lib/aws-rds/lib/serverless-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DatabaseSecret } from './database-secret';
import { Endpoint } from './endpoint';
import type { IParameterGroup } from './parameter-group';
import { DATA_API_ACTIONS } from './perms';
import { applyDefaultRotationOptions, defaultDeletionProtection, renderCredentials } from './private/util';
import { applyDefaultRotationOptions, defaultDeletionProtection, renderCredentials, helperRemovalPolicy, renderUnless } from './private/util';
import type { Credentials, RotationMultiUserOptions, RotationSingleUserOptions, SnapshotCredentials } from './props';
import type { CfnDBClusterProps } from './rds.generated';
import { CfnDBCluster } from './rds.generated';
Expand Down Expand Up @@ -472,7 +472,7 @@ abstract class ServerlessClusterNew extends ServerlessClusterBase {
description: `Subnets for ${id} database`,
vpc: props.vpc,
vpcSubnets: props.vpcSubnets,
removalPolicy: props.removalPolicy === RemovalPolicy.RETAIN ? props.removalPolicy : undefined,
removalPolicy: renderUnless(helperRemovalPolicy(props.removalPolicy), RemovalPolicy.DESTROY),
});

this.securityGroups = props.securityGroups ?? [
Expand Down
Loading