Skip to content

Commit

Permalink
feat(rds): add support for update and backup properties to Cluster in…
Browse files Browse the repository at this point in the history
…stances (#10324)

fixes #9926

Added the following parameters to DatabaseCluster.
* AutoMinorVersionUpgrade
* AllowMajorVersionUpgrade
* DeleteAutomatedBackups

#10092 as a reference, only defined simple parameters.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
hixi-hyi committed Sep 24, 2020
1 parent 8ec1cfe commit 4a4c154
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-rds/lib/cluster.ts
Expand Up @@ -716,6 +716,9 @@ function createInstances(cluster: DatabaseClusterNew, props: DatabaseClusterBase
dbParameterGroupName: instanceParameterGroupConfig?.parameterGroupName,
monitoringInterval: props.monitoringInterval && props.monitoringInterval.toSeconds(),
monitoringRoleArn: monitoringRole && monitoringRole.roleArn,
autoMinorVersionUpgrade: props.instanceProps.autoMinorVersionUpgrade,
allowMajorVersionUpgrade: props.instanceProps.allowMajorVersionUpgrade,
deleteAutomatedBackups: props.instanceProps.deleteAutomatedBackups,
});

// If removalPolicy isn't explicitly set,
Expand Down
21 changes: 21 additions & 0 deletions packages/@aws-cdk/aws-rds/lib/props.ts
Expand Up @@ -63,6 +63,27 @@ export interface InstanceProps {
* @default - default master key
*/
readonly performanceInsightEncryptionKey?: kms.IKey;

/**
* Whether to enable automatic upgrade of minor version for the DB instance.
*
* @default - true
*/
readonly autoMinorVersionUpgrade?: boolean;

/**
* Whether to allow upgrade of major version for the DB instance.
*
* @default - false
*/
readonly allowMajorVersionUpgrade?: boolean;

/**
* Whether to remove automated backups immediately after the DB instance is deleted for the DB instance.
*
* @default - true
*/
readonly deleteAutomatedBackups?: boolean;
}

/**
Expand Down
63 changes: 63 additions & 0 deletions packages/@aws-cdk/aws-rds/test/test.cluster.ts
Expand Up @@ -373,6 +373,69 @@ export = {
},
},

'cluster with disable automatic upgrade of minor version'(test: Test) {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AURORA,
instanceProps: {
autoMinorVersionUpgrade: false,
vpc,
},
});

expect(stack).to(haveResource('AWS::RDS::DBInstance', {
AutoMinorVersionUpgrade: false,
}));

test.done();
},

'cluster with allow upgrade of major version'(test: Test) {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AURORA,
instanceProps: {
allowMajorVersionUpgrade: true,
vpc,
},
});

expect(stack).to(haveResourceLike('AWS::RDS::DBInstance', {
AllowMajorVersionUpgrade: true,
}));

test.done();
},

'cluster with disallow remove backups'(test: Test) {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AURORA,
instanceProps: {
deleteAutomatedBackups: false,
vpc,
},
});

expect(stack).to(haveResourceLike('AWS::RDS::DBInstance', {
DeleteAutomatedBackups: false,
}));

test.done();
},

'create a cluster using a specific version of MySQL'(test: Test) {
// GIVEN
const stack = testStack();
Expand Down

0 comments on commit 4a4c154

Please sign in to comment.