Repository: aws-cloudformation/cfn-lint

Issue:
E3686 Additional properties are not allowed ('ScalingConfiguration')
### CloudFormation Lint Version

1.3.2

### What operating system are you using?

Ubuntu

### Describe the bug

AWS::RDS::DBCluster has a scalilng configuration option for serverless databases V1 and is defined here
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html#cfn-rds-dbcluster-scalingconfiguration


### Expected behavior

Do not report that that ScalingConfiguration is not allowed.

### Reproduction template

```yaml

  Db:
    Type: AWS::RDS::DBCluster
    DeletionPolicy: Retain
    UpdateReplacePolicy: Retain
    Properties:
      DatabaseName: 'MyDb'
      ScalingConfiguration:
        AutoPause: true
        SecondsUntilAutoPause: 1200
        MaxCapacity: 64
      Engine: aurora-postgresql
      EngineMode: serverless
      EngineVersion: '13.12'
      MasterUsername: 'x'
      MasterUserPassword: 'y'
      StorageEncrypted: true
      DeletionProtection: true

```


Discussion:

Patch:
diff --git a/src/cfnlint/data/schemas/extensions/aws_rds_dbcluster/serverless_exclusive.json b/src/cfnlint/data/schemas/extensions/aws_rds_dbcluster/serverless_exclusive.json
index 53976a2ef7..5976fa7642 100644
--- a/src/cfnlint/data/schemas/extensions/aws_rds_dbcluster/serverless_exclusive.json
+++ b/src/cfnlint/data/schemas/extensions/aws_rds_dbcluster/serverless_exclusive.json
@@ -1,21 +1,56 @@
 {
  "additionalProperties": true,
- "description": "When creating a serverless 'EngineMode' don't specify 'ScalingConfiguration'",
- "else": {},
- "if": {
-  "properties": {
-   "EngineMode": {
-    "const": "serverless"
+ "allOf": [
+  {
+   "if": {
+    "properties": {
+     "EngineMode": {
+      "const": "provisioned"
+     }
+    },
+    "required": [
+     "EngineMode"
+    ],
+    "type": "object"
+   },
+   "then": {
+    "properties": {
+     "ScalingConfiguration": false
+    }
    }
   },
-  "required": [
-   "EngineMode"
-  ],
-  "type": "object"
- },
- "then": {
-  "properties": {
-   "ScalingConfiguration": false
+  {
+   "if": {
+    "properties": {
+     "EngineMode": {
+      "const": "serverless"
+     }
+    },
+    "required": [
+     "EngineMode"
+    ],
+    "type": "object"
+   },
+   "then": {
+    "properties": {
+     "ServerlessV2ScalingConfiguration": false
+    }
+   }
+  },
+  {
+   "if": {
+    "properties": {
+     "EngineMode": false
+    },
+    "type": "object"
+   },
+   "then": {
+    "properties": {
+     "ScalingConfiguration": false,
+     "ServerlessV2ScalingConfiguration": false
+    }
+   }
   }
- }
+ ],
+ "description": "When creating a serverless 'EngineMode' don't specify 'ServerlessV2ScalingConfiguration'"
 }
diff --git a/src/cfnlint/rules/resources/rds/DbClusterServerlessExclusive.py b/src/cfnlint/rules/resources/rds/DbClusterServerlessExclusive.py
index 2540c634df..3e66e62521 100644
--- a/src/cfnlint/rules/resources/rds/DbClusterServerlessExclusive.py
+++ b/src/cfnlint/rules/resources/rds/DbClusterServerlessExclusive.py
@@ -14,11 +14,11 @@
 
 class DbClusterServerlessExclusive(CfnLintJsonSchema):
     id = "E3686"
-    shortdesc = (
-        "Validate when using a serverless RDS DB certain properties aren't needed"
-    )
+    shortdesc = "Validate allowed properties when using a serverless RDS DB cluster"
     description = (
-        "When creating a serverless 'EngineMode' don't specify 'ScalingConfiguration'"
+        "Validate that when EngineMode is 'serverless' or 'provisioned' that the "
+        "appropriate allowed properties are provided. If 'EngineMode' is not provided "
+        "make sure serverless properties don't exist at all."
     )
     tags = ["resources"]
 
@@ -32,4 +32,15 @@ def __init__(self) -> None:
         )
 
     def message(self, instance: Any, err: ValidationError) -> str:
-        return "Additional properties are not allowed ('ScalingConfiguration')"
+
+        # validator None means the schema is falsy
+        if err.validator is None:
+            if instance.get("EngineMode") in ["serverless", "provisioned"]:
+                return (
+                    f"EngineMode {instance.get('EngineMode')!r} "
+                    f" doesn't allow additional properties {err.path[0]!r}"
+                )
+            else:
+                return "Additional properties are not allowed " f"({err.path[0]!r})"
+
+        return err.message


Test patch:
diff --git a/test/unit/rules/resources/rds/test_db_cluster_serverless_exclusive.py b/test/unit/rules/resources/rds/test_db_cluster_serverless_exclusive.py
index 2d8d2e51d1..ca90c590b8 100644
--- a/test/unit/rules/resources/rds/test_db_cluster_serverless_exclusive.py
+++ b/test/unit/rules/resources/rds/test_db_cluster_serverless_exclusive.py
@@ -35,14 +35,82 @@ def rule():
             [],
         ),
         (
-            {"EngineMode": "serverless", "ScalingConfiguration": "foo"},
+            {"EngineMode": "serverless", "ServerlessV2ScalingConfiguration": "foo"},
             [
                 ValidationError(
-                    "Additional properties are not allowed ('ScalingConfiguration')",
+                    (
+                        "EngineMode 'serverless'  doesn't allow additional "
+                        "properties 'ServerlessV2ScalingConfiguration'"
+                    ),
+                    rule=DbClusterServerlessExclusive(),
+                    path=deque(["ServerlessV2ScalingConfiguration"]),
+                    validator=None,
+                    schema_path=deque(
+                        [
+                            "allOf",
+                            1,
+                            "then",
+                            "properties",
+                            "ServerlessV2ScalingConfiguration",
+                        ]
+                    ),
+                )
+            ],
+        ),
+        (
+            {"EngineMode": "provisioned", "ScalingConfiguration": "foo"},
+            [
+                ValidationError(
+                    (
+                        "EngineMode 'provisioned'  doesn't allow "
+                        "additional properties 'ScalingConfiguration'"
+                    ),
+                    rule=DbClusterServerlessExclusive(),
+                    path=deque(["ScalingConfiguration"]),
+                    validator=None,
+                    schema_path=deque(
+                        ["allOf", 0, "then", "properties", "ScalingConfiguration"]
+                    ),
+                )
+            ],
+        ),
+        (
+            {"ServerlessV2ScalingConfiguration": "foo"},
+            [
+                ValidationError(
+                    (
+                        "Additional properties are not allowed "
+                        "('ServerlessV2ScalingConfiguration')"
+                    ),
+                    rule=DbClusterServerlessExclusive(),
+                    path=deque(["ServerlessV2ScalingConfiguration"]),
+                    validator=None,
+                    schema_path=deque(
+                        [
+                            "allOf",
+                            2,
+                            "then",
+                            "properties",
+                            "ServerlessV2ScalingConfiguration",
+                        ]
+                    ),
+                )
+            ],
+        ),
+        (
+            {"ScalingConfiguration": "foo"},
+            [
+                ValidationError(
+                    (
+                        "Additional properties are not allowed "
+                        "('ScalingConfiguration')"
+                    ),
                     rule=DbClusterServerlessExclusive(),
                     path=deque(["ScalingConfiguration"]),
                     validator=None,
-                    schema_path=deque(["then", "properties", "ScalingConfiguration"]),
+                    schema_path=deque(
+                        ["allOf", 2, "then", "properties", "ScalingConfiguration"]
+                    ),
                 )
             ],
         ),
@@ -50,5 +118,4 @@ def rule():
 )
 def test_validate(instance, expected, rule, validator):
     errs = list(rule.validate(validator, "", instance, {}))
-
     assert errs == expected, f"Expected {expected} got {errs}"