We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
E0002 parsing I3013 on AWS::RDS::DBInstance if Engine is a Ref
### CloudFormation Lint Version

0.65.0

### What operating system are you using?

Ubuntu 22.04

### Describe the bug

A cfn-lint exception is raised when parsing I3013 rule.

The trigger seems to be the presence of a reference as a value of the "Engine" resource parameter.

![Screenshot from 2022-09-29 13-57-09](https://user-images.githubusercontent.com/1442700/193029918-32a6b143-06c4-4707-834b-b9ea0c262c74.png)
![Screenshot from 2022-09-29 13-58-10](https://user-images.githubusercontent.com/1442700/193029945-c8d06db4-4513-4389-89eb-70ea6f51296e.png)
![Screenshot from 2022-09-29 14-15-37](https://user-images.githubusercontent.com/1442700/193029965-83f97802-cc82-459a-ac09-d424430ccb4e.png)



### Expected behavior

No error should be present is `Engine: !Ref Something` is used.

### Reproduction template

```yaml
---
AWSTemplateFormatVersion: 2010-09-09

Parameters:

  Engine:
    Description: DB Engine
    Type: String
    AllowedValues:
      - aurora-mysql
      - aurora-postgresql


Resources:

  DbCluster:
    Type: AWS::RDS::DBCluster
    DeletionPolicy: Snapshot
    UpdateReplacePolicy: Retain
    Properties:
      DBClusterIdentifier: FooBar
      Engine: !Ref Engine
      StorageEncrypted: true
      ## XXX Other properties removed for brevity

  DbWriterInstance:
    Type: AWS::RDS::DBInstance
    DeletionPolicy: Snapshot
    UpdateReplacePolicy: Retain
    Properties:
      DBClusterIdentifier: !Ref DbCluster
      Engine: !Ref Engine  # XXX here a cfn-lint bug. Allowed parameter values are "aurora-postgresql" and "aurora-mysql"
      PubliclyAccessible: false
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py`
Content:
```
1 """
2 Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 SPDX-License-Identifier: MIT-0
4 """
5 import re
6 from cfnlint.rules import CloudFormationLintRule
7 from cfnlint.rules import RuleMatch
8 
9 
10 class RetentionPeriodOnResourceTypesWithAutoExpiringContent(CloudFormationLintRule):
11     """Check for RetentionPeriod """
12     id = 'I3013'
13     shortdesc = 'Check resources with auto expiring content have explicit retention period'
14     description = 'The behaviour for data retention is different across AWS Services.'\
15                   'If no retention period is specified the default for some services is to delete the data after a period of time.' \
16                   'This check requires you to explicitly set the retention period for those resources to avoid unexpected data losses'
17     source_url = 'https://github.com/aws-cloudformation/cfn-python-lint'
18     tags = ['resources', 'retentionperiod']
19 
20     def _check_ref(self, value, parameters, resources, path):  # pylint: disable=W0613
21         print(value)
22 
23     def match(self, cfn):
24         """Check for RetentionPeriod"""
25         matches = []
26 
27         retention_attributes_by_resource_type = {
28             'AWS::Kinesis::Stream': [
29                 {
30                     'Attribute': 'RetentionPeriodHours',
31                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kinesis-stream.html#cfn-kinesis-stream-retentionperiodhours'
32                 }
33             ],
34             'AWS::SQS::Queue':  [
35                 {
36                     'Attribute': 'MessageRetentionPeriod',
37                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html#aws-sqs-queue-msgretentionperiod'
38                 }
39             ],
40             'AWS::DocDB::DBCluster': [
41                 {
42                     'Attribute': 'BackupRetentionPeriod',
43                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-docdb-dbcluster.html#cfn-docdb-dbcluster-backupretentionperiod'
44                 }
45             ],
46             'AWS::Synthetics::Canary': [
47                 {
48                     'Attribute': 'SuccessRetentionPeriod',
49                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-successretentionperiod'
50                 },
51                 {
52                     'Attribute': 'FailureRetentionPeriod',
53                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-failureretentionperiod'
54                 }
55             ],
56             'AWS::Redshift::Cluster': [
57                 {
58                     'Attribute': 'AutomatedSnapshotRetentionPeriod',
59                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-redshift-cluster.html#cfn-redshift-cluster-automatedsnapshotretentionperiod'
60                 }
61             ],
62             'AWS::RDS::DBInstance': [
63                 {
64                     'Attribute': 'BackupRetentionPeriod',
65                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-backupretentionperiod',
66                     'CheckAttribute': 'Engine',
67                     'CheckAttributeRegex': re.compile('^((?!aurora).)*$'),
68                 }
69             ],
70             'AWS::RDS::DBCluster': [
71                 {
72                     'Attribute': 'BackupRetentionPeriod',
73                     'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html#cfn-rds-dbcluster-backuprententionperiod'
74                 }
75             ]
76         }
77 
78         resources = cfn.get_resources()
79         for r_name, r_values in resources.items():
80             if r_values.get('Type') in retention_attributes_by_resource_type:
81                 for attr_def in retention_attributes_by_resource_type[r_values.get('Type')]:
82                     property_sets = r_values.get_safe('Properties')
83                     for property_set, path in property_sets:
84                         error_path = ['Resources', r_name] + path
85                         if not property_set:
86                             message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {"/".join(str(x) for x in error_path)}'
87                             matches.append(RuleMatch(error_path, message))
88                         else:
89                             value = property_set.get(attr_def.get('Attribute'))
90                             if not value:
91                                 message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {"/".join(str(x) for x in error_path)}'
92                                 if attr_def.get('CheckAttribute'):
93                                     if self._validate_property(property_set.get(attr_def.get('CheckAttribute')), attr_def.get('CheckAttributeRegex')):
94                                         matches.append(RuleMatch(error_path, message))
95                                 else:
96                                     matches.append(RuleMatch(error_path, message))
97                             if isinstance(value, dict):
98                                 # pylint: disable=protected-access
99                                 refs = cfn._search_deep_keys(
100                                     'Ref', value, error_path + [attr_def.get('Attribute')])
101                                 for ref in refs:
102                                     if ref[-1] == 'AWS::NoValue':
103                                         message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {"/".join(str(x) for x in ref[0:-1])}'
104                                         matches.append(RuleMatch(ref[0:-1], message))
105 
106         return matches
107 
108     def _validate_property(self, value, regex) -> bool:
109         if regex.match(value):
110             return True
111         return False
112
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py b/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py
--- a/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py
+++ b/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py
@@ -106,6 +106,8 @@
         return matches
 
     def _validate_property(self, value, regex) -> bool:
-        if regex.match(value):
-            return True
-        return False
+        if isinstance(value, str):
+            if regex.match(value):
+                return True
+            return False
+        return True

{"golden_diff": "diff --git a/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py b/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py\n--- a/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py\n+++ b/src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py\n@@ -106,6 +106,8 @@\n         return matches\n \n     def _validate_property(self, value, regex) -> bool:\n-        if regex.match(value):\n-            return True\n-        return False\n+        if isinstance(value, str):\n+            if regex.match(value):\n+                return True\n+            return False\n+        return True\n", "issue": "E0002 parsing I3013 on AWS::RDS::DBInstance if Engine is a Ref\n### CloudFormation Lint Version\n\n0.65.0\n\n### What operating system are you using?\n\nUbuntu 22.04\n\n### Describe the bug\n\nA cfn-lint exception is raised when parsing I3013 rule.\r\n\r\nThe trigger seems to be the presence of a reference as a value of the \"Engine\" resource parameter.\r\n\r\n![Screenshot from 2022-09-29 13-57-09](https://user-images.githubusercontent.com/1442700/193029918-32a6b143-06c4-4707-834b-b9ea0c262c74.png)\r\n![Screenshot from 2022-09-29 13-58-10](https://user-images.githubusercontent.com/1442700/193029945-c8d06db4-4513-4389-89eb-70ea6f51296e.png)\r\n![Screenshot from 2022-09-29 14-15-37](https://user-images.githubusercontent.com/1442700/193029965-83f97802-cc82-459a-ac09-d424430ccb4e.png)\r\n\r\n\n\n### Expected behavior\n\nNo error should be present is `Engine: !Ref Something` is used.\n\n### Reproduction template\n\n```yaml\r\n---\r\nAWSTemplateFormatVersion: 2010-09-09\r\n\r\nParameters:\r\n\r\n  Engine:\r\n    Description: DB Engine\r\n    Type: String\r\n    AllowedValues:\r\n      - aurora-mysql\r\n      - aurora-postgresql\r\n\r\n\r\nResources:\r\n\r\n  DbCluster:\r\n    Type: AWS::RDS::DBCluster\r\n    DeletionPolicy: Snapshot\r\n    UpdateReplacePolicy: Retain\r\n    Properties:\r\n      DBClusterIdentifier: FooBar\r\n      Engine: !Ref Engine\r\n      StorageEncrypted: true\r\n      ## XXX Other properties removed for brevity\r\n\r\n  DbWriterInstance:\r\n    Type: AWS::RDS::DBInstance\r\n    DeletionPolicy: Snapshot\r\n    UpdateReplacePolicy: Retain\r\n    Properties:\r\n      DBClusterIdentifier: !Ref DbCluster\r\n      Engine: !Ref Engine  # XXX here a cfn-lint bug. Allowed parameter values are \"aurora-postgresql\" and \"aurora-mysql\"\r\n      PubliclyAccessible: false\r\n```\n", "before_files": [{"content": "\"\"\"\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport re\nfrom cfnlint.rules import CloudFormationLintRule\nfrom cfnlint.rules import RuleMatch\n\n\nclass RetentionPeriodOnResourceTypesWithAutoExpiringContent(CloudFormationLintRule):\n    \"\"\"Check for RetentionPeriod \"\"\"\n    id = 'I3013'\n    shortdesc = 'Check resources with auto expiring content have explicit retention period'\n    description = 'The behaviour for data retention is different across AWS Services.'\\\n                  'If no retention period is specified the default for some services is to delete the data after a period of time.' \\\n                  'This check requires you to explicitly set the retention period for those resources to avoid unexpected data losses'\n    source_url = 'https://github.com/aws-cloudformation/cfn-python-lint'\n    tags = ['resources', 'retentionperiod']\n\n    def _check_ref(self, value, parameters, resources, path):  # pylint: disable=W0613\n        print(value)\n\n    def match(self, cfn):\n        \"\"\"Check for RetentionPeriod\"\"\"\n        matches = []\n\n        retention_attributes_by_resource_type = {\n            'AWS::Kinesis::Stream': [\n                {\n                    'Attribute': 'RetentionPeriodHours',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kinesis-stream.html#cfn-kinesis-stream-retentionperiodhours'\n                }\n            ],\n            'AWS::SQS::Queue':  [\n                {\n                    'Attribute': 'MessageRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html#aws-sqs-queue-msgretentionperiod'\n                }\n            ],\n            'AWS::DocDB::DBCluster': [\n                {\n                    'Attribute': 'BackupRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-docdb-dbcluster.html#cfn-docdb-dbcluster-backupretentionperiod'\n                }\n            ],\n            'AWS::Synthetics::Canary': [\n                {\n                    'Attribute': 'SuccessRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-successretentionperiod'\n                },\n                {\n                    'Attribute': 'FailureRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-failureretentionperiod'\n                }\n            ],\n            'AWS::Redshift::Cluster': [\n                {\n                    'Attribute': 'AutomatedSnapshotRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-redshift-cluster.html#cfn-redshift-cluster-automatedsnapshotretentionperiod'\n                }\n            ],\n            'AWS::RDS::DBInstance': [\n                {\n                    'Attribute': 'BackupRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-backupretentionperiod',\n                    'CheckAttribute': 'Engine',\n                    'CheckAttributeRegex': re.compile('^((?!aurora).)*$'),\n                }\n            ],\n            'AWS::RDS::DBCluster': [\n                {\n                    'Attribute': 'BackupRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html#cfn-rds-dbcluster-backuprententionperiod'\n                }\n            ]\n        }\n\n        resources = cfn.get_resources()\n        for r_name, r_values in resources.items():\n            if r_values.get('Type') in retention_attributes_by_resource_type:\n                for attr_def in retention_attributes_by_resource_type[r_values.get('Type')]:\n                    property_sets = r_values.get_safe('Properties')\n                    for property_set, path in property_sets:\n                        error_path = ['Resources', r_name] + path\n                        if not property_set:\n                            message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {\"/\".join(str(x) for x in error_path)}'\n                            matches.append(RuleMatch(error_path, message))\n                        else:\n                            value = property_set.get(attr_def.get('Attribute'))\n                            if not value:\n                                message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {\"/\".join(str(x) for x in error_path)}'\n                                if attr_def.get('CheckAttribute'):\n                                    if self._validate_property(property_set.get(attr_def.get('CheckAttribute')), attr_def.get('CheckAttributeRegex')):\n                                        matches.append(RuleMatch(error_path, message))\n                                else:\n                                    matches.append(RuleMatch(error_path, message))\n                            if isinstance(value, dict):\n                                # pylint: disable=protected-access\n                                refs = cfn._search_deep_keys(\n                                    'Ref', value, error_path + [attr_def.get('Attribute')])\n                                for ref in refs:\n                                    if ref[-1] == 'AWS::NoValue':\n                                        message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {\"/\".join(str(x) for x in ref[0:-1])}'\n                                        matches.append(RuleMatch(ref[0:-1], message))\n\n        return matches\n\n    def _validate_property(self, value, regex) -> bool:\n        if regex.match(value):\n            return True\n        return False\n", "path": "src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py"}], "after_files": [{"content": "\"\"\"\nCopyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\nSPDX-License-Identifier: MIT-0\n\"\"\"\nimport re\nfrom cfnlint.rules import CloudFormationLintRule\nfrom cfnlint.rules import RuleMatch\n\n\nclass RetentionPeriodOnResourceTypesWithAutoExpiringContent(CloudFormationLintRule):\n    \"\"\"Check for RetentionPeriod \"\"\"\n    id = 'I3013'\n    shortdesc = 'Check resources with auto expiring content have explicit retention period'\n    description = 'The behaviour for data retention is different across AWS Services.'\\\n                  'If no retention period is specified the default for some services is to delete the data after a period of time.' \\\n                  'This check requires you to explicitly set the retention period for those resources to avoid unexpected data losses'\n    source_url = 'https://github.com/aws-cloudformation/cfn-python-lint'\n    tags = ['resources', 'retentionperiod']\n\n    def _check_ref(self, value, parameters, resources, path):  # pylint: disable=W0613\n        print(value)\n\n    def match(self, cfn):\n        \"\"\"Check for RetentionPeriod\"\"\"\n        matches = []\n\n        retention_attributes_by_resource_type = {\n            'AWS::Kinesis::Stream': [\n                {\n                    'Attribute': 'RetentionPeriodHours',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-kinesis-stream.html#cfn-kinesis-stream-retentionperiodhours'\n                }\n            ],\n            'AWS::SQS::Queue':  [\n                {\n                    'Attribute': 'MessageRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sqs-queues.html#aws-sqs-queue-msgretentionperiod'\n                }\n            ],\n            'AWS::DocDB::DBCluster': [\n                {\n                    'Attribute': 'BackupRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-docdb-dbcluster.html#cfn-docdb-dbcluster-backupretentionperiod'\n                }\n            ],\n            'AWS::Synthetics::Canary': [\n                {\n                    'Attribute': 'SuccessRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-successretentionperiod'\n                },\n                {\n                    'Attribute': 'FailureRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-synthetics-canary.html#cfn-synthetics-canary-failureretentionperiod'\n                }\n            ],\n            'AWS::Redshift::Cluster': [\n                {\n                    'Attribute': 'AutomatedSnapshotRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-redshift-cluster.html#cfn-redshift-cluster-automatedsnapshotretentionperiod'\n                }\n            ],\n            'AWS::RDS::DBInstance': [\n                {\n                    'Attribute': 'BackupRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-rds-database-instance.html#cfn-rds-dbinstance-backupretentionperiod',\n                    'CheckAttribute': 'Engine',\n                    'CheckAttributeRegex': re.compile('^((?!aurora).)*$'),\n                }\n            ],\n            'AWS::RDS::DBCluster': [\n                {\n                    'Attribute': 'BackupRetentionPeriod',\n                    'SourceUrl': 'http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-rds-dbcluster.html#cfn-rds-dbcluster-backuprententionperiod'\n                }\n            ]\n        }\n\n        resources = cfn.get_resources()\n        for r_name, r_values in resources.items():\n            if r_values.get('Type') in retention_attributes_by_resource_type:\n                for attr_def in retention_attributes_by_resource_type[r_values.get('Type')]:\n                    property_sets = r_values.get_safe('Properties')\n                    for property_set, path in property_sets:\n                        error_path = ['Resources', r_name] + path\n                        if not property_set:\n                            message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {\"/\".join(str(x) for x in error_path)}'\n                            matches.append(RuleMatch(error_path, message))\n                        else:\n                            value = property_set.get(attr_def.get('Attribute'))\n                            if not value:\n                                message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {\"/\".join(str(x) for x in error_path)}'\n                                if attr_def.get('CheckAttribute'):\n                                    if self._validate_property(property_set.get(attr_def.get('CheckAttribute')), attr_def.get('CheckAttributeRegex')):\n                                        matches.append(RuleMatch(error_path, message))\n                                else:\n                                    matches.append(RuleMatch(error_path, message))\n                            if isinstance(value, dict):\n                                # pylint: disable=protected-access\n                                refs = cfn._search_deep_keys(\n                                    'Ref', value, error_path + [attr_def.get('Attribute')])\n                                for ref in refs:\n                                    if ref[-1] == 'AWS::NoValue':\n                                        message = f'The default retention period will delete the data after a pre-defined time. Set an explicit values to avoid data loss on resource : {\"/\".join(str(x) for x in ref[0:-1])}'\n                                        matches.append(RuleMatch(ref[0:-1], message))\n\n        return matches\n\n    def _validate_property(self, value, regex) -> bool:\n        if isinstance(value, str):\n            if regex.match(value):\n                return True\n            return False\n        return True\n", "path": "src/cfnlint/rules/resources/RetentionPeriodOnResourceTypesWithAutoExpiringContent.py"}]}