Skip to content

Commit

Permalink
fix(rds): correctly expose DatabaseCluster's read endpoint (#2970)
Browse files Browse the repository at this point in the history
Fix a typo that exposes cluster write endpoint as `clusterReadEndpoint` on RDS DatabaseCluster

Fixes #2969.
  • Loading branch information
rpanfili authored and rix0rrr committed Jun 21, 2019
1 parent a6e4f6a commit 2d50c18
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export class DatabaseCluster extends DatabaseClusterBase {
// create a number token that represents the port of the cluster
const portAttribute = Token.asNumber(cluster.attrEndpointPort);
this.clusterEndpoint = new Endpoint(cluster.attrEndpointAddress, portAttribute);
this.clusterReadEndpoint = new Endpoint(cluster.attrEndpointAddress, portAttribute);
this.clusterReadEndpoint = new Endpoint(cluster.attrReadEndpointAddress, portAttribute);

if (secret) {
this.secret = secret.addTargetAttachment('AttachedSecret', {
Expand Down
26 changes: 26 additions & 0 deletions packages/@aws-cdk/aws-rds/test/test.cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,32 @@ export = {
EngineVersion: "10.7",
}));

test.done();
},

'cluster exposes different read and write endpoints'(test: Test) {
// GIVEN
const stack = testStack();
const vpc = new ec2.Vpc(stack, 'VPC');

// WHEN
const cluster = new DatabaseCluster(stack, 'Database', {
engine: DatabaseClusterEngine.Aurora,
masterUser: {
username: 'admin',
},
instanceProps: {
instanceType: new ec2.InstanceTypePair(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.SMALL),
vpc
}
});

// THEN
test.notDeepEqual(
stack.resolve(cluster.clusterEndpoint),
stack.resolve(cluster.clusterReadEndpoint)
);

test.done();
}
};
Expand Down

0 comments on commit 2d50c18

Please sign in to comment.