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 engineVersion to DatabaseCluster #2698

Merged
merged 2 commits into from
Jun 3, 2019
Merged
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
9 changes: 9 additions & 0 deletions packages/@aws-cdk/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ export interface DatabaseClusterProps {
*/
readonly engine: DatabaseClusterEngine;

/**
* What version of the database to start
*
* @default - The default for the engine is used.
*/
readonly engineVersion?: string;

/**
* How many replicas/instances to create
*
Expand Down Expand Up @@ -292,6 +299,7 @@ export class DatabaseCluster extends DatabaseClusterBase {
const cluster = new CfnDBCluster(this, 'Resource', {
// Basic
engine: props.engine.name,
engineVersion: props.engineVersion,
dbClusterIdentifier: props.clusterIdentifier,
dbSubnetGroupName: subnetGroup.ref,
vpcSecurityGroupIds: [this.securityGroupId],
Expand Down Expand Up @@ -349,6 +357,7 @@ export class DatabaseCluster extends DatabaseClusterBase {
const instance = new CfnDBInstance(this, `Instance${instanceIndex}`, {
// Link to cluster
engine: props.engine.name,
engineVersion: props.engineVersion,
dbClusterIdentifier: cluster.ref,
dbInstanceIdentifier: instanceIdentifier,
// Instance properties
Expand Down
54 changes: 54 additions & 0 deletions packages/@aws-cdk/aws-rds/test/test.cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,60 @@ export = {
test.done();

},

'create a cluster using a specific version of MySQL'(test: Test) {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AuroraMysql,
engineVersion: "5.7.mysql_aurora.2.04.4",
masterUser: {
username: 'admin'
},
instanceProps: {
instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.Burstable2, ec2.InstanceSize.Small),
vpc
},
});

// THEN
expect(stack).to(haveResource('AWS::RDS::DBCluster', {
Engine: "aurora-mysql",
EngineVersion: "5.7.mysql_aurora.2.04.4",
}));

test.done();
},

'create a cluster using a specific version of Postgresql'(test: Test) {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.AuroraPostgresql,
engineVersion: "10.7",
masterUser: {
username: 'admin'
},
instanceProps: {
instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.Burstable2, ec2.InstanceSize.Small),
vpc
},
});

// THEN
expect(stack).to(haveResource('AWS::RDS::DBCluster', {
Engine: "aurora-postgresql",
EngineVersion: "10.7",
}));

test.done();
}
};

function testStack() {
Expand Down