From 4e2e5fe784d6e7b2a94e426d5fbff7fda4297ae8 Mon Sep 17 00:00:00 2001 From: Prasanth Louis Date: Wed, 3 Apr 2024 13:23:25 -0400 Subject: [PATCH 1/2] Update cluster.ts Just an idea/I was curious. Why do we have separate error messages here vs just using the same error message? Personally, when I stumbled upon this error I got a bit confused. But I really like the top error message of 'Provide either vpc or instanceProps.vpc, but not both" --- packages/aws-cdk-lib/aws-rds/lib/cluster.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/aws-cdk-lib/aws-rds/lib/cluster.ts b/packages/aws-cdk-lib/aws-rds/lib/cluster.ts index 5119f57a3dec5..586ae6f0d8ba0 100644 --- a/packages/aws-cdk-lib/aws-rds/lib/cluster.ts +++ b/packages/aws-cdk-lib/aws-rds/lib/cluster.ts @@ -588,10 +588,8 @@ abstract class DatabaseClusterNew extends DatabaseClusterBase { constructor(scope: Construct, id: string, props: DatabaseClusterBaseProps) { super(scope, id); - if ((props.vpc && props.instanceProps?.vpc)) { + if ((props.vpc && props.instanceProps?.vpc) || (!props.vpc && !props.instanceProps?.vpc)) { throw new Error('Provide either vpc or instanceProps.vpc, but not both'); - } else if (!props.vpc && !props.instanceProps?.vpc) { - throw new Error('If instanceProps is not provided then `vpc` must be provided.'); } if ((props.vpcSubnets && props.instanceProps?.vpcSubnets)) { throw new Error('Provide either vpcSubnets or instanceProps.vpcSubnets, but not both'); From f8bb08f82488bf5292f1ccbc9229660f78c0bc3d Mon Sep 17 00:00:00 2001 From: Prasanth Louis Date: Wed, 10 Apr 2024 10:46:55 -0400 Subject: [PATCH 2/2] Update cluster.test.ts --- packages/aws-cdk-lib/aws-rds/test/cluster.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts b/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts index b3a67928987b5..1414c490db236 100644 --- a/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts +++ b/packages/aws-cdk-lib/aws-rds/test/cluster.test.ts @@ -67,7 +67,7 @@ describe('cluster new api', () => { iamAuthentication: true, }); // THEN - }).toThrow(/If instanceProps is not provided then `vpc` must be provided./); + }).toThrow(/Provide either vpc or instanceProps.vpc, but not both/); }); test('when both vpc and instanceProps.vpc are provided', () => {