aws-cdk: Cannot create Aurora Serverless cluster using RDS Construct
There doesn’t seem to be a way to create an Aurora Serverless database cluster using the RDS Construct. EngineMode is available in the underlying cfn but not in the Construct library.
Target Framework: netcoreapp2.1 Amazon.CDK: 0.12.0 Amazon.CDK.AWS.RDS: 0.12.0
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 74
- Comments: 30 (8 by maintainers)
Is there any progress on this?
It would be really helpful to have an L2 construct for Aurora Serverless DB cluster including Data API, secret rotation, and methods to easily grant read/write access Lambdas or AppSync.
I set this up for our usage, it’s ugly, but it may be of use to someone who needs a “quick and dirty” version of Serverless Aurora:
Please ignore the lack of comments, and possibly broken code, I removed some proprietary information. 🤕
Working construct with CDK 1.55.0
I think creating a separate resource is probably the best option considering most of the options on the current cluster type don’t quite apply. E.g only MySQL and Postgres are available, and you can’t call lambdas from stored procedures or queries, etc.
Serverless also has the “Web API” feature that may be useful to turn on from some stacks. (Though, I’m not sure that it’s currently supported in Cfn)
You can use Escape Hatches to modify the L2 Aurora Server construct into a Serverless version:
This doc shows how to do property overrides.
Thanks for reporting. As a workaround, you should be able to use property overrides
I built on some of the work by @ApocDev and @StevenAskwith, in case it helps anyone else here:
@skinny85
This still seems problematic (or at least not clearly documented).
For instance,
engine.bindToClusteris required - but what is it? I don’t see it documented anywhere. The docs say it’s a method, but when I’m defining my cluster usingrds.ServerlessCluster, it treats it as a required property.Also, why are
singleUserRotationApplicationandmultiUserRotationApplicationneeded? I’ve created a serverless cluster in CloudFormation YAML before and not needed these.Lastly, it seems impossible to create a serverless cluster without NAT gateways, which are not required. If I use isolated subnets for the
rds.SubnetGroup, it complains:Error: There are no 'Private' subnet groups in this VPC. Available types: Isolated,PublicBut if I create private subnets in my VPC definition, NAT gateways are automatically created. Setting
natGateways: 0complains that I should use isolated subnets—so you can see my catch-22 here.Expand to see definition
I would use this
@skinny85 No sir! This wound up working fine for me:
(expand for code)
I made some progress on this, but there are still some questionable things going on.
Here’s my definition of my serverless cluster using
CfnDbCluster:Here’s the
ServerlessClusterversion of that:I get this error when trying to deploy:
Error: There are no 'Private' subnet groups in this VPC. Available types: PublicYet using
CfnDbCluster, it works fine. Why are private subnets required when they’re really not? The security group is only so a dev can manually connect to the DB via SSH within SSM… otherwise it’s not needed since I’m using the Data API.this article saved my day 🙇 🙇 🙇
I see, would it be preferable to add a “Serverless” Database Prop or instead change DatabaseClusterProps to support “Serverless” configurations?
No. The DatabaseCluster doesn’t expose the
engineModeandscalingConfigurationproperties. It also has other property requirements that are only valid for non-serverless instances. (Instance type, size, etc) Those options are not available in the serverless mode.