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

feat(rds): Aurora clusters from snapshots #17759

Merged
merged 10 commits into from
Dec 18, 2021

Conversation

jumic
Copy link
Contributor

@jumic jumic commented Nov 29, 2021

Add DatabaseClusterFromSnapshot to support creating Aurora clusters from snapshots.

Closes #10936.

The logic is implemented similar to PR #10130 where the same feature was implemented for database clusters.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@gitpod-io
Copy link

gitpod-io bot commented Nov 29, 2021

@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Nov 29, 2021
@skinny85
Copy link
Contributor

Thanks for the contribution @jumic!

@jogold do you mind taking a first pass on this one?

@skinny85
Copy link
Contributor

skinny85 commented Dec 9, 2021

Thanks @jogold!

Copy link
Contributor Author

@jumic jumic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

@jumic
Copy link
Contributor Author

jumic commented Dec 9, 2021

Thanks for your review, @jogold. I implemented the suggested changes.

I also took over the test cases from rds Instance where more test cases were available than in rds cluster. Should I also manually deploy the combinations that used in the unit tests? I deployed a Aurora cluster from a snapshot before submitting this PR. However, I have not yet tested all combinations from the unit tests.

@jumic
Copy link
Contributor Author

jumic commented Dec 9, 2021

@skinny85 PR is ready for review again. (I can't request your review in GitHub in the current state.)

Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @jumic! The API looks good, we just need to reduce the duplication a little bit before we merge this in.

packages/@aws-cdk/aws-rds/test/serverless-cluster.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/test/serverless-cluster.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/test/serverless-cluster.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/test/serverless-cluster.test.ts Outdated Show resolved Hide resolved
packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts Outdated Show resolved Hide resolved
Comment on lines 682 to 685
this.connections = new ec2.Connections({
securityGroups: this.securityGroups,
defaultPort: ec2.Port.tcp(this.clusterEndpoint.port),
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this up to ServerlessClusterNew? I believe this is duplicated between ServerlessClusterFromSnapshot and ServerlessCluster.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment on lines 687 to 691
if (secret) {
this.secret = secret.attach(this);
}

cluster.applyRemovalPolicy(props.removalPolicy ?? RemovalPolicy.SNAPSHOT);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - can we move this up to ServerlessClusterNew?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to do so.

secret is a readonly property. We can assign it only in the constructer. So I think we can't move it up to ServerlessClusterNew because the source value isn't available yet.

cluster.applyRemovalPolicy could be moved to a new method renderApplyRemovalPolicy(cluster: CfnCluster, removalPolicy?: RemovalPolicy). Then, we could call this method in ServerlessClusterFromSnapshot and ServerlessCluster. Should I implement it this way? I'm not sure if this is really a good optimisation.

In instance.ts those lines are also duplicated. Maybe because there is no better option. Or do you have other ideas? If so, please let me know.

packages/@aws-cdk/aws-rds/README.md Outdated Show resolved Hide resolved
public static fromServerlessClusterAttributes(scope: Construct, id: string,
attrs: ServerlessClusterAttributes): IServerlessCluster {
protected readonly newCfnProps: CfnDBClusterProps;
protected readonly subnetGroup: ISubnetGroup;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a field, and protected? I don't see it used anywhere outside of this class' constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied this line from cluster.ts. You're right. I was able to remove field subnetGroup.

@mergify mergify bot dismissed skinny85’s stale review December 17, 2021 21:29

Pull request has been modified.

@jumic jumic requested a review from skinny85 December 17, 2021 21:35
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @jumic! One more tiny naming change please before we merge this in.

packages/@aws-cdk/aws-rds/lib/serverless-cluster.ts Outdated Show resolved Hide resolved
public readonly clusterIdentifier: string;
public readonly clusterEndpoint: Endpoint;
public readonly clusterReadEndpoint: Endpoint;
protected enableDataApi?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this up to ServerlessClusterNew?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enableDataApi --> done

If I move the readonly fields to ServerlessClusterNew, it shows message Property 'clusterIdentifier' has no initializer and is not definitely assigned in the constructor.. I could declare them as abstract. However, then I still have to create those fields in the sub classes.


public readonly secret?: secretsmanager.ISecret;

protected enableDataApi?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this up to ServerlessClusterNew?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enableDataApi --> done

readonly field: see comment above.

@mergify mergify bot dismissed skinny85’s stale review December 17, 2021 22:43

Pull request has been modified.

@jumic jumic requested a review from skinny85 December 17, 2021 22:47
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @jumic, thanks for the contribution!

@mergify
Copy link
Contributor

mergify bot commented Dec 17, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: f88fff7
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify mergify bot merged commit e5259ee into aws:master Dec 18, 2021
@mergify
Copy link
Contributor

mergify bot commented Dec 18, 2021

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
Add `DatabaseClusterFromSnapshot` to support creating Aurora clusters from snapshots.

Closes aws#10936.

The logic is implemented similar to PR aws#10130 where the same feature was implemented for database clusters.

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[aws-rds] ServerlessCluster Snapshot Restore
4 participants