Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(rds): improve error messages for providing a vpc to cluster #29706

Merged
merged 7 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions packages/aws-cdk-lib/aws-rds/lib/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk-lib/aws-rds/test/cluster.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down