-
Notifications
You must be signed in to change notification settings - Fork 4k
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
fix(rds): do not allow aurora engines when using DatabaseInstance #5367
Conversation
Aurora instances can only be created inside a cluster and should use the `DatabaseCluster` construct. Closes aws#5345
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
5 similar comments
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
Thanks so much for taking the time to contribute to the AWS CDK ❤️ We will shortly assign someone to review this pull request and help get it
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion / question.
@@ -670,6 +670,10 @@ abstract class DatabaseInstanceSource extends DatabaseInstanceNew implements IDa | |||
constructor(scope: Construct, id: string, props: DatabaseInstanceSourceProps) { | |||
super(scope, id, props); | |||
|
|||
if (/aurora/.test(props.engine.name)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I love this test...
How about a method on Engine
, something like get allowedOutsideCluster(): boolean
(name TBD of course)? Then, this code could be:
if (!props.engine.allowedOutsideCluster) {
throw new Error(`${props.engine.name} instances can only be created inside a cluster. Please use the DatabaseCluster class instead`);
}
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually just a public readonly isDatabaseInstanceEngine = true;
in DatabaseInstanceEngine
is enough no? Because then the typing system will not allow to use a DatabaseInstanceCluster
for a DatabaseInstance
and we don't need to check anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep. This works:
export class DatabaseInstanceEngine extends DatabaseClusterEngine {
// ...
/** To make it a compile-time error to pass a DatabaseClusterEngine where a DatabaseInstanceEngine is expected. */
public readonly isDatabaseInstanceEngine = true;
}
Having it be a compile-time error is even better than adding runtime validation.
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jogold !
Thank you for contributing! Your pull request is now being automatically merged. |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request is now being automatically merged. |
Aurora instances can only be created inside a cluster and should use the
DatabaseCluster
construct.Closes #5345
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license