From 7cf432b41203680c001f629c037175da8c13640a Mon Sep 17 00:00:00 2001 From: Bert Blommers Date: Mon, 28 Aug 2023 07:29:52 +0000 Subject: [PATCH] RDS: Clusters now support the ServerlessV2ScalingConfiguration parameter (#6736) --- moto/rds/models.py | 9 +++++++++ moto/rds/responses.py | 8 +++++--- tests/test_rds/test_rds_clusters.py | 8 ++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/moto/rds/models.py b/moto/rds/models.py index 10020677b..8405171e7 100644 --- a/moto/rds/models.py +++ b/moto/rds/models.py @@ -208,6 +208,9 @@ class Cluster: "timeout_action": "RollbackCapacityChange", "seconds_before_timeout": 300, } + self.serverless_v2_scaling_configuration = kwargs.get( + "serverless_v2_scaling_configuration" + ) self.cluster_members: List[str] = list() self.replication_source_identifier = kwargs.get("replication_source_identifier") self.read_replica_identifiers: List[str] = list() @@ -378,6 +381,12 @@ class Cluster: {% if "seconds_before_timeout" in cluster.scaling_configuration %}{{ cluster.scaling_configuration["seconds_before_timeout"] }}{% endif %} {% endif %} + {% if cluster.serverless_v2_scaling_configuration %} + + {% if "MinCapacity" in cluster.serverless_v2_scaling_configuration %}{{ cluster.serverless_v2_scaling_configuration["MinCapacity"] }}{% endif %} + {% if "MaxCapacity" in cluster.serverless_v2_scaling_configuration %}{{ cluster.serverless_v2_scaling_configuration["MaxCapacity"] }}{% endif %} + + {% endif %} {%- if cluster.global_cluster_identifier -%} {{ cluster.global_cluster_identifier }} {%- endif -%} diff --git a/moto/rds/responses.py b/moto/rds/responses.py index 1ef2bb3f5..001734ef9 100644 --- a/moto/rds/responses.py +++ b/moto/rds/responses.py @@ -178,13 +178,12 @@ class RDSResponse(BaseResponse): } def _get_db_cluster_kwargs(self) -> Dict[str, Any]: + params = self._get_params() return { "availability_zones": self._get_multi_param( "AvailabilityZones.AvailabilityZone" ), - "enable_cloudwatch_logs_exports": self._get_params().get( - "EnableCloudwatchLogsExports" - ), + "enable_cloudwatch_logs_exports": params.get("EnableCloudwatchLogsExports"), "db_name": self._get_param("DatabaseName"), "db_cluster_identifier": self._get_param("DBClusterIdentifier"), "db_subnet_group_name": self._get_param("DBSubnetGroupName"), @@ -208,6 +207,9 @@ class RDSResponse(BaseResponse): "copy_tags_to_snapshot": self._get_param("CopyTagsToSnapshot"), "tags": self.unpack_list_params("Tags", "Tag"), "scaling_configuration": self._get_dict_param("ScalingConfiguration."), + "serverless_v2_scaling_configuration": params.get( + "ServerlessV2ScalingConfiguration" + ), "replication_source_identifier": self._get_param( "ReplicationSourceIdentifier" ), diff --git a/tests/test_rds/test_rds_clusters.py b/tests/test_rds/test_rds_clusters.py index c047e276e..3190bc8ae 100644 --- a/tests/test_rds/test_rds_clusters.py +++ b/tests/test_rds/test_rds_clusters.py @@ -219,6 +219,10 @@ def test_create_db_cluster_additional_parameters(): "MinCapacity": 5, "AutoPause": True, }, + ServerlessV2ScalingConfiguration={ + "MinCapacity": 2, + "MaxCapacity": 4, + }, VpcSecurityGroupIds=["sg1", "sg2"], ) @@ -236,6 +240,10 @@ def test_create_db_cluster_additional_parameters(): assert cluster["NetworkType"] == "IPV4" assert cluster["DBSubnetGroup"] == "subnetgroupname" assert cluster["ScalingConfigurationInfo"] == {"MinCapacity": 5, "AutoPause": True} + assert cluster["ServerlessV2ScalingConfiguration"] == { + "MaxCapacity": 4.0, + "MinCapacity": 2.0, + } security_groups = cluster["VpcSecurityGroups"] assert len(security_groups) == 2