diff --git a/packages/aws-cdk-lib/aws-rds/lib/cluster.ts b/packages/aws-cdk-lib/aws-rds/lib/cluster.ts index 5dbaa0a8b0604..05997a4a09ec2 100644 --- a/packages/aws-cdk-lib/aws-rds/lib/cluster.ts +++ b/packages/aws-cdk-lib/aws-rds/lib/cluster.ts @@ -595,10 +595,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'); 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 20ca5417b6303..d27abfb4a8065 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', () => {