diff --git a/moto/rds/models.py b/moto/rds/models.py index 1c51dd7df..9680e46e0 100644 --- a/moto/rds/models.py +++ b/moto/rds/models.py @@ -114,6 +114,31 @@ class Cluster: self.enabled_cloudwatch_logs_exports = ( kwargs.get("enable_cloudwatch_logs_exports") or [] ) + self.enable_http_endpoint = False + # instead of raising an error on aws rds create-db-cluster commands with + # incompatible configurations with enable_http_endpoint + # (e.g. engine_mode is not set to "serverless"), the API + # automatically sets the enable_http_endpoint parameter to False + if kwargs.get("enable_http_endpoint"): + if self.engine_mode == "serverless": + if self.engine == "aurora-mysql" and self.engine_version in [ + "5.6.10a", + "5.6.1", + "2.07.1", + "5.7.2", + ]: + self.enable_http_endpoint = kwargs.get( + "enable_http_endpoint", False + ) + elif self.engine == "aurora-postgresql" and self.engine_version in [ + "10.12", + "10.14", + "10.18", + "11.13", + ]: + self.enable_http_endpoint = kwargs.get( + "enable_http_endpoint", False + ) @property def db_cluster_arn(self): @@ -170,7 +195,7 @@ class Cluster: false {{ cluster.engine_mode }} {{ 'true' if cluster.deletion_protection else 'false' }} - false + {{ cluster.enable_http_endpoint }} {{ cluster.copy_tags_to_snapshot }} false diff --git a/moto/rds/responses.py b/moto/rds/responses.py index 862f34444..badb0dea9 100644 --- a/moto/rds/responses.py +++ b/moto/rds/responses.py @@ -117,6 +117,7 @@ class RDSResponse(BaseResponse): "parameter_group": self._get_param("DBClusterParameterGroup"), "region": self.region, "db_cluster_instance_class": self._get_param("DBClusterInstanceClass"), + "enable_http_endpoint": self._get_param("EnableHttpEndpoint"), "copy_tags_to_snapshot": self._get_param("CopyTagsToSnapshot"), "tags": self.unpack_complex_list_params("Tags.Tag", ("Key", "Value")), } diff --git a/tests/test_rds/test_rds_clusters.py b/tests/test_rds/test_rds_clusters.py index 010998916..2078688f4 100644 --- a/tests/test_rds/test_rds_clusters.py +++ b/tests/test_rds/test_rds_clusters.py @@ -716,3 +716,39 @@ def test_add_tags_to_cluster_snapshot(): tags = conn.list_tags_for_resource(ResourceName=snapshot_arn)["TagList"] tags.should.equal([{"Key": "k2", "Value": "v2"}]) + + +@mock_rds +def test_create_db_cluster_with_enable_http_endpoint_valid(): + client = boto3.client("rds", region_name="eu-north-1") + + resp = client.create_db_cluster( + DBClusterIdentifier="cluster-id", + DatabaseName="users", + Engine="aurora-mysql", + EngineMode="serverless", + EngineVersion="5.6.10a", + MasterUsername="root", + MasterUserPassword="hunter2_", + EnableHttpEndpoint=True, + ) + cluster = resp["DBCluster"] + cluster.should.have.key("HttpEndpointEnabled").equal(True) + + +@mock_rds +def test_create_db_cluster_with_enable_http_endpoint_invalid(): + client = boto3.client("rds", region_name="eu-north-1") + + resp = client.create_db_cluster( + DBClusterIdentifier="cluster-id", + DatabaseName="users", + Engine="aurora-mysql", + EngineMode="serverless", + EngineVersion="5.7.0", + MasterUsername="root", + MasterUserPassword="hunter2_", + EnableHttpEndpoint=True, + ) + cluster = resp["DBCluster"] + cluster.should.have.key("HttpEndpointEnabled").equal(False)