From fea8853bf5b7d770681564c9156e7c30d340dca3 Mon Sep 17 00:00:00 2001 From: Rubens Panfili Date: Fri, 21 Jun 2019 12:14:53 +0200 Subject: [PATCH] fix(rds): DatabaseCluster exposes read endpoint Fix a typo that exposes cluster write endpoint as `clusterReadEndpoint` on RDS DatabaseCluster fixes #2969 --- packages/@aws-cdk/aws-rds/lib/cluster.ts | 2 +- .../@aws-cdk/aws-rds/test/test.cluster.ts | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/@aws-cdk/aws-rds/lib/cluster.ts b/packages/@aws-cdk/aws-rds/lib/cluster.ts index 3f108534ff012..9c2b9b7d86d80 100644 --- a/packages/@aws-cdk/aws-rds/lib/cluster.ts +++ b/packages/@aws-cdk/aws-rds/lib/cluster.ts @@ -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', { diff --git a/packages/@aws-cdk/aws-rds/test/test.cluster.ts b/packages/@aws-cdk/aws-rds/test/test.cluster.ts index 0d69e4c6ca341..0161c38ff0a17 100644 --- a/packages/@aws-cdk/aws-rds/test/test.cluster.ts +++ b/packages/@aws-cdk/aws-rds/test/test.cluster.ts @@ -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(); } };