From e878f9c5fd503615a4d65a3f866e80cff001a309 Mon Sep 17 00:00:00 2001 From: Daniel Neilson <53624638+ddneilson@users.noreply.github.com> Date: Sun, 9 Aug 2020 06:04:17 -0500 Subject: [PATCH] fix(docdb): `autoMinorVersionUpgrade` property was not set to `true` by default as stated in the docstring (#9505) Fixes https://github.com/aws/aws-cdk/issues/9494 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-docdb/lib/instance.ts | 2 +- .../@aws-cdk/aws-docdb/test/instance.test.ts | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-docdb/lib/instance.ts b/packages/@aws-cdk/aws-docdb/lib/instance.ts index cdefa1d155f9f..7c69c626703d4 100644 --- a/packages/@aws-cdk/aws-docdb/lib/instance.ts +++ b/packages/@aws-cdk/aws-docdb/lib/instance.ts @@ -203,7 +203,7 @@ export class DatabaseInstance extends DatabaseInstanceBase implements IDatabaseI const instance = new CfnDBInstance(this, 'Resource', { dbClusterIdentifier: props.cluster.clusterIdentifier, dbInstanceClass: `db.${props.instanceClass}`, - autoMinorVersionUpgrade: props.autoMinorVersionUpgrade, + autoMinorVersionUpgrade: props.autoMinorVersionUpgrade ?? true, availabilityZone: props.availabilityZone, dbInstanceIdentifier: props.dbInstanceName, preferredMaintenanceWindow: props.preferredMaintenanceWindow, diff --git a/packages/@aws-cdk/aws-docdb/test/instance.test.ts b/packages/@aws-cdk/aws-docdb/test/instance.test.ts index b36d6af554ef1..197e2e296fd8d 100644 --- a/packages/@aws-cdk/aws-docdb/test/instance.test.ts +++ b/packages/@aws-cdk/aws-docdb/test/instance.test.ts @@ -24,6 +24,34 @@ describe('DatabaseInstance', () => { Properties: { DBClusterIdentifier: { Ref: 'DatabaseB269D8BB' }, DBInstanceClass: EXPECTED_SYNTH_INSTANCE_TYPE, + AutoMinorVersionUpgrade: true, + }, + DeletionPolicy: 'Retain', + UpdateReplacePolicy: 'Retain', + }, ResourcePart.CompleteDefinition)); + }); + + test.each([ + [undefined, true], + [true, true], + [false, false], + ])('check that autoMinorVersionUpdate works: %p', (given: boolean | undefined, expected: boolean) => { + // GIVEN + const stack = testStack(); + + // WHEN + new DatabaseInstance(stack, 'Instance', { + cluster: stack.cluster, + instanceClass: SINGLE_INSTANCE_TYPE, + autoMinorVersionUpgrade: given, + }); + + // THEN + expectCDK(stack).to(haveResource('AWS::DocDB::DBInstance', { + Properties: { + DBClusterIdentifier: { Ref: 'DatabaseB269D8BB' }, + DBInstanceClass: EXPECTED_SYNTH_INSTANCE_TYPE, + AutoMinorVersionUpgrade: expected, }, DeletionPolicy: 'Retain', UpdateReplacePolicy: 'Retain',