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

aws-rds: support zero instances in DatabaseCluster #26724

Open
2 tasks
plumdog opened this issue Aug 11, 2023 · 3 comments
Open
2 tasks

aws-rds: support zero instances in DatabaseCluster #26724

plumdog opened this issue Aug 11, 2023 · 3 comments
Labels
@aws-cdk/aws-rds Related to Amazon Relational Database effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3

Comments

@plumdog
Copy link
Contributor

plumdog commented Aug 11, 2023

Describe the feature

Both "old style" with instances: number and "new style" with writer: and readers: require that you end up with at least one instance in your cluster. Aurora doesn't actually require this, and further is actually a recommended approach to retaining data without spending money running instances. Per https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_DeleteCluster.html#USER_DeleteInstance.Empty:

You can keep a cluster with no DB instances to preserve your data without incurring CPU charges for the cluster. You can quickly start using the cluster again by creating one or more new DB instances for the cluster. You can perform Aurora-specific administrative operations on the cluster while it doesn't have any associated DB instances. You just can't access the data or perform any operations that require connecting to a DB instance.

CDK should accommodate this.

Use Case

Retaining Aurora data without running any instances, per https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_DeleteCluster.html#USER_DeleteInstance.Empty

Proposed Solution

Adjust the props to accommodate this.

Other Information

Workaround:

const myDatabaseCluster = new rds.DatabaseCluster(this, 'MyDatabaseCluster', {
    // ...
    instanceProps: {
        instances: 1,
    },
});
myDatabaseCluster.node.tryRemoveChild('Instance1');

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.83.0

Environment details (OS name and version, etc.)

n/a

@plumdog plumdog added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Aug 11, 2023
@github-actions github-actions bot added the @aws-cdk/aws-rds Related to Amazon Relational Database label Aug 11, 2023
@pahud
Copy link
Contributor

pahud commented Aug 14, 2023

Makes sense to me. Can you explain a little bit about this use case? I assume you would have created a cluster with at least 1 writer instance and you just want to re-deploy your CDK application to remove that writer instance but retain the cluster itself so when you create a new writer again the data would still be accessible. Is it correct?

Have you tried your workaround? What happened when you not specify the instance for the cluster? Will the cluster be removed by cloudformation?

@pahud pahud added p2 effort/medium Medium work item – several days of effort and removed needs-triage This issue or PR still needs to be triaged. labels Aug 14, 2023
@plumdog
Copy link
Contributor Author

plumdog commented Aug 14, 2023

@pahud My use case is to allow my application to have a "hibernate" mode. I have an application running on ECS and the Aurora database. I have a few different non-production configurations of this deployed separately that I want to be able to easily power up and down to accommodate testing.

The zero-instance-cluster approach is preferable because it removes the need to think about snapshots, which would require locating the right snapshot when powering up, and means my code can just have an on/off switch: I change the switch, push it to git, the pipeline deploys it, and everything comes back up. (The downside of this approach is that Aurora storage is 5x more expensive per GB than snapshots, $0.10 per GB-month for Aurora storage vs $0.021 per GB-month for snapshots (in us-east-1, at least). As I'm storing <10 GB across my several near-copies of this stack, this cost is negligible compared to the benefit of the pipeline being able to just switch the app back on.)

My workaround did work, and Cloudformation did not remove the cluster. This delete-the-cluster-when-deleting-the-last-instance behaviour appears to be unique to the web console, and this is documented here https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/USER_DeleteCluster.html#USER_DeleteCluster.DeleteCluster.

@pahud
Copy link
Contributor

pahud commented Aug 15, 2023

Makes perfect sense to me and appreciate your workaround. This is currently marked as p2 which means we expect community to contribute the pull request. Feel free to submit any pull request for it. Thank you.

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 effort/medium Medium work item – several days of effort feature-request A feature should be added or improved. p3
Projects
None yet
Development

No branches or pull requests

2 participants