Repository: getmoto/moto

Issue:
RDS cluster with instances can be deleted in moto
If a cluster has instances, the cluster cannot be deleted, but we can do delete cluster even with instances in moto.
I'd like to try on this issue :)

Reference:
https://repost.aws/knowledge-center/rds-error-delete-aurora-cluster

```python
from moto import mock_rds


@mock_rds
def test_delete_rds_instance():
    target_cluster_identifier = "test-cluster"
    target_instance_identifier = "test-instance"
    rds_client = boto3.client("rds")
    rds_client.create_db_cluster(
        DBClusterIdentifier=target_cluster_identifier,
        Engine="aurora-postgresql",
        MasterUsername="test-user",
        MasterUserPassword="password",
    )
    rds_client.create_db_instance(
        DBClusterIdentifier=target_cluster_identifier,
        Engine="aurora-postgresql",
        DBInstanceIdentifier=target_instance_identifier,
        DBInstanceClass="db.t4g.medium",
    )

   # Cluster can be deleted here.
   client.delete_db_cluster(
        DBClusterIdentifier=cluster_identifier,
        SkipFinalSnapshot=True,
    )

```


Discussion:

Resolving patch:
diff --git a/moto/rds/exceptions.py b/moto/rds/exceptions.py
--- a/moto/rds/exceptions.py
+++ b/moto/rds/exceptions.py
@@ -82,6 +82,14 @@ def __init__(self, database_identifier: str):
         )
 
 
+class DBClusterToBeDeletedHasActiveMembers(RDSClientError):
+    def __init__(self) -> None:
+        super().__init__(
+            "InvalidDBClusterStateFault",
+            "Cluster cannot be deleted, it still contains DB instances in non-deleting state.",
+        )
+
+
 class InvalidDBInstanceStateError(RDSClientError):
     def __init__(self, database_identifier: str, istate: str):
         estate = (
diff --git a/moto/rds/models.py b/moto/rds/models.py
--- a/moto/rds/models.py
+++ b/moto/rds/models.py
@@ -19,6 +19,7 @@
     DBClusterNotFoundError,
     DBClusterSnapshotAlreadyExistsError,
     DBClusterSnapshotNotFoundError,
+    DBClusterToBeDeletedHasActiveMembers,
     DBInstanceNotFoundError,
     DBSnapshotNotFoundError,
     DBSecurityGroupNotFoundError,
@@ -2339,7 +2340,8 @@ def delete_db_cluster(
                 raise InvalidParameterValue(
                     "Can't delete Cluster with protection enabled"
                 )
-
+            if cluster.cluster_members:
+                raise DBClusterToBeDeletedHasActiveMembers()
             global_id = cluster.global_cluster_identifier or ""
             if global_id in self.global_clusters:
                 self.remove_from_global_cluster(global_id, cluster_identifier)


Test patch:
diff --git a/tests/test_rds/test_rds_clusters_with_instances.py b/tests/test_rds/test_rds_clusters_with_instances.py
--- a/tests/test_rds/test_rds_clusters_with_instances.py
+++ b/tests/test_rds/test_rds_clusters_with_instances.py
@@ -89,3 +89,42 @@ def test_add_instance_to_serverless_cluster():
     err = exc.value.response["Error"]
     assert err["Code"] == "InvalidParameterValue"
     assert err["Message"] == "Instances cannot be added to Aurora Serverless clusters."
+
+
+@mock_rds
+def test_delete_db_cluster_fails_if_cluster_contains_db_instances():
+    cluster_identifier = "test-cluster"
+    instance_identifier = "test-instance"
+    client = boto3.client("rds", "us-east-1")
+    client.create_db_cluster(
+        DBClusterIdentifier=cluster_identifier,
+        Engine="aurora-postgresql",
+        MasterUsername="test-user",
+        MasterUserPassword="password",
+    )
+    client.create_db_instance(
+        DBClusterIdentifier=cluster_identifier,
+        Engine="aurora-postgresql",
+        DBInstanceIdentifier=instance_identifier,
+        DBInstanceClass="db.t4g.medium",
+    )
+    with pytest.raises(ClientError) as exc:
+        client.delete_db_cluster(
+            DBClusterIdentifier=cluster_identifier,
+            SkipFinalSnapshot=True,
+        )
+    err = exc.value.response["Error"]
+    assert err["Code"] == "InvalidDBClusterStateFault"
+    assert (
+        err["Message"]
+        == "Cluster cannot be deleted, it still contains DB instances in non-deleting state."
+    )
+    client.delete_db_instance(
+        DBInstanceIdentifier=instance_identifier,
+        SkipFinalSnapshot=True,
+    )
+    cluster = client.delete_db_cluster(
+        DBClusterIdentifier=cluster_identifier,
+        SkipFinalSnapshot=True,
+    ).get("DBCluster")
+    assert cluster["DBClusterIdentifier"] == cluster_identifier