aws / aws-cdk

The AWS Cloud Development Kit is a framework for defining cloud infrastructure in code
https://aws.amazon.com/cdk
Apache License 2.0
11.7k stars 3.93k forks source link

DatabaseCluster: serverlessV2MinCapacity should allow scaling to 0 #32234

Closed tehnrd closed 3 days ago

tehnrd commented 4 days ago

Describe the feature

Aurora Serverless V2 now allows scaling to zero (https://aws.amazon.com/blogs/database/introducing-scaling-to-0-capacity-with-amazon-aurora-serverless-v2/), but there is validation in CDK that prevents any values less than 0.5.

This validation needs to be removed.

Use Case

You should be able to scale the Aurora Serverless V2 cluster to 0.

Proposed Solution

Modfity /packages/aws-cdk-lib/aws-rds/lib/cluster.ts and remove the greater that 0.5 validation.

Other Information

No response

Acknowledgements

CDK version used

2.168.0

Environment details (OS name and version, etc.)

OSX 15.0 (24A335)

pahud commented 4 days ago

This feature is amazing and I've seen @mazyu36 on https://github.com/aws/aws-cdk/pull/32231

Thank you.

tmokmss commented 3 days ago

Workaround to avoid the validation:


    const cluster = new rds.DatabaseCluster(this, 'Cluster', {
      engine,
      vpc,
      serverlessV2MinCapacity: 0.5,
      serverlessV2MaxCapacity: 2.0,
      writer: rds.ClusterInstance.serverlessV2(this.writerId, {
        autoMinorVersionUpgrade: true,
        publiclyAccessible: false,
      }),
      storageEncrypted: true,
      removalPolicy: RemovalPolicy.DESTROY,
      parameterGroup: new rds.ParameterGroup(this, 'ParameterGroup', {
        engine,
        parameters: {
          // Terminate idle session for Aurora Serverless V2 auto-pause
          idle_session_timeout: '60000',
        },
      }),
    });
    // ADD THIS!
    (cluster.node.defaultChild as CfnResource).addPropertyOverride('ServerlessV2ScalingConfiguration.MinCapacity', 0);
github-actions[bot] commented 3 days ago

Comments on closed issues and PRs are hard for our team to see. If you need help, please open a new issue that references this one.