Skip to content

Commit

Permalink
fix(rds): DatabaseCluster exposes read endpoint
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 committed Jun 21, 2019
1 parent 0dabb02 commit 8f7ca98
Show file tree
Hide file tree
Showing 2 changed files with 28 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
27 changes: 27 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,33 @@ 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',
password: SecretValue.plainText('tooshort'),
},
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 8f7ca98

Please sign in to comment.