Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rds): add support for update and backup properties to Cluster instances #10324

Merged
3 changes: 3 additions & 0 deletions packages/@aws-cdk/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
*/
skinny85 marked this conversation as resolved.
Show resolved Hide resolved
readonly autoMinorVersionUpgrade?: boolean;

/**
hixi-hyi marked this conversation as resolved.
Show resolved Hide resolved
* Whether to allow upgrade of major version for the DB instance.
*
* @default - false
*/
readonly allowMajorVersionUpgrade?: boolean;

/**
hixi-hyi marked this conversation as resolved.
Show resolved Hide resolved
* 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
Original file line number Diff line number Diff line change
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