RDS Auora serverless scale to zero CDK¶
Aurora lets you scale to zero capacity per this AWS blog post.
CDK lib doesn’t support this and if you pass 0
to the MinCapacity
you will
get an validation error:
serverlessV2MinCapacity must be >= 0.5 & <= 256
This is fixed in cdk-lib version v2.171.0.
If for some reason you don’t want to upgrade just now you can work around this with the following:
const cfnCluster = dbCluster.node.defaultChild as rds.CfnDBCluster
cfnCluster.addPropertyOverride(
'ServerlessV2ScalingConfiguration.MinCapacity',
0
)
The most important thing to know is that RDS will auto scale to zero when there are no longer any connections, when a new connection is sent it can take ~15 seconds for the connecting client to get a response and so client code might need to be configured to handle this delay:
Server=db-instance.endpoint;Port=5432;Database=database;User Id=username;Password=password;Connect Timeout=30;
Comments
comments powered by Disqus