We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
W2030 Default value required on conditionally included property
*cfn-lint version: 0.21.3*

CloudFormation provides the AWS::NoValue pseudo-parameter, which allows for a property to be included based on a given Condition. However, cfn-lint will still validate the potential value provided for the property, even if it will not actually be used in the deployment.

Example template:

```yaml
Parameters:
  Retention:
    Type: Number
    Description: Retention in days for the log group (-1 for no retention)
    Default: -1
Conditions:
  IsRetention: 
    !Not [!Equals [!Ref 'Retention', '-1']]
Resources:
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      LogGroupName: 'some-log-group'
      RetentionInDays: !If [IsRetention, !Ref Retention, !Ref 'AWS::NoValue']
```

This template allows the user to specify the retention on a log group, or use the number -1 if they wish to have unlimited retention. This is achieved via a Condition as well as an If block that conditionally includes the property.

This leads to the following linter output:

```
cfn-lint --template template.yaml
W2030 You must specify a valid Default value for Retention (-1).   
Valid values are ['1', '3', '5', '7', '14', '30', '60', '90', '120', '150', '180', '365', '400', '545', '731', '1827', '3653']
cloudformation/template.yaml:5:5
```

This can of course be avoided by disabling this specific check in the template Metadata block. Unfortunately it cannot be disabled in the resource Metadata, as the validation error happens on the Parameter:

```yaml
Metadata:
  cfn-lint:
    config:
      ignore_checks:
        - W2030
```

This might be a difficult situation to account for, since it would require the Condition to be evaluated to determine whether the property itself should even be checked.

--- 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/parameters/AllowedValue.py`
Content:
```
1 """
2   Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 
4   Permission is hereby granted, free of charge, to any person obtaining a copy of this
5   software and associated documentation files (the "Software"), to deal in the Software
6   without restriction, including without limitation the rights to use, copy, modify,
7   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
8   permit persons to whom the Software is furnished to do so.
9 
10   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
11   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
12   PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
13   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
14   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
15   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16 """
17 import six
18 from cfnlint.rules import CloudFormationLintRule
19 from cfnlint.rules import RuleMatch
20 
21 from cfnlint.helpers import RESOURCE_SPECS
22 
23 
24 class AllowedValue(CloudFormationLintRule):
25     """Check if parameters have a valid value"""
26     id = 'W2030'
27     shortdesc = 'Check if parameters have a valid value'
28     description = 'Check if parameters have a valid value in case of an enumator. The Parameter''s allowed values is based on the usages in property (Ref)'
29     source_url = 'https://github.com/aws-cloudformation/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedvalue'
30     tags = ['resources', 'property', 'allowed value']
31 
32     def initialize(self, cfn):
33         """Initialize the rule"""
34         for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes'):
35             self.resource_property_types.append(resource_type_spec)
36         for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):
37             self.resource_sub_property_types.append(property_type_spec)
38 
39     def check_value_ref(self, value, path, **kwargs):
40         """Check Ref"""
41         matches = []
42 
43         if 'Fn::If' in path:
44             self.logger.debug('Not able to guarentee that the default value hasn\'t been conditioned out')
45             return matches
46 
47         allowed_value_specs = kwargs.get('value_specs', {}).get('AllowedValues', {})
48         cfn = kwargs.get('cfn')
49 
50         if allowed_value_specs:
51             if value in cfn.template.get('Parameters', {}):
52                 param = cfn.template.get('Parameters').get(value, {})
53                 parameter_values = param.get('AllowedValues')
54                 default_value = param.get('Default')
55                 parameter_type = param.get('Type')
56                 if isinstance(parameter_type, six.string_types):
57                     if ((not parameter_type.startswith('List<')) and
58                             (not parameter_type.startswith('AWS::SSM::Parameter::Value<')) and
59                             parameter_type not in ['CommaDelimitedList', 'List<String>']):
60                         # Check Allowed Values
61                         if parameter_values:
62                             for index, allowed_value in enumerate(parameter_values):
63                                 if str(allowed_value) not in allowed_value_specs:
64                                     param_path = ['Parameters', value, 'AllowedValues', index]
65                                     message = 'You must specify a valid allowed value for {0} ({1}).\nValid values are {2}'
66                                     matches.append(RuleMatch(param_path, message.format(value, allowed_value, allowed_value_specs)))
67                         if default_value:
68                             # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)
69                             if str(default_value) not in allowed_value_specs:
70                                 param_path = ['Parameters', value, 'Default']
71                                 message = 'You must specify a valid Default value for {0} ({1}).\nValid values are {2}'
72                                 matches.append(RuleMatch(param_path, message.format(value, default_value, allowed_value_specs)))
73 
74         return matches
75 
76     def check(self, cfn, properties, value_specs, property_specs, path):
77         """Check itself"""
78         matches = list()
79         for p_value, p_path in properties.items_safe(path[:]):
80             for prop in p_value:
81                 if prop in value_specs:
82                     value = value_specs.get(prop).get('Value', {})
83                     if value:
84                         value_type = value.get('ValueType', '')
85                         property_type = property_specs.get('Properties').get(prop).get('Type')
86                         matches.extend(
87                             cfn.check_value(
88                                 p_value, prop, p_path,
89                                 check_ref=self.check_value_ref,
90                                 value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),
91                                 cfn=cfn, property_type=property_type, property_name=prop
92                             )
93                         )
94 
95         return matches
96 
97     def match_resource_sub_properties(self, properties, property_type, path, cfn):
98         """Match for sub properties"""
99         matches = list()
100 
101         specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})
102         property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)
103         matches.extend(self.check(cfn, properties, specs, property_specs, path))
104 
105         return matches
106 
107     def match_resource_properties(self, properties, resource_type, path, cfn):
108         """Check CloudFormation Properties"""
109         matches = list()
110 
111         specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})
112         resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)
113         matches.extend(self.check(cfn, properties, specs, resource_specs, path))
114 
115         return matches
116
```
--- 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/parameters/AllowedValue.py b/src/cfnlint/rules/parameters/AllowedValue.py
--- a/src/cfnlint/rules/parameters/AllowedValue.py
+++ b/src/cfnlint/rules/parameters/AllowedValue.py
@@ -40,12 +40,19 @@
         """Check Ref"""
         matches = []
 
+        cfn = kwargs.get('cfn')
         if 'Fn::If' in path:
-            self.logger.debug('Not able to guarentee that the default value hasn\'t been conditioned out')
+            self.logger.debug(
+                'Not able to guarentee that the default value hasn\'t been conditioned out')
+            return matches
+        if path[0] == 'Resources' and 'Condition' in cfn.template.get(
+                path[0], {}).get(path[1]):
+            self.logger.debug(
+                'Not able to guarentee that the default value '
+                'hasn\'t been conditioned out')
             return matches
 
         allowed_value_specs = kwargs.get('value_specs', {}).get('AllowedValues', {})
-        cfn = kwargs.get('cfn')
 
         if allowed_value_specs:
             if value in cfn.template.get('Parameters', {}):
@@ -63,13 +70,15 @@
                                 if str(allowed_value) not in allowed_value_specs:
                                     param_path = ['Parameters', value, 'AllowedValues', index]
                                     message = 'You must specify a valid allowed value for {0} ({1}).\nValid values are {2}'
-                                    matches.append(RuleMatch(param_path, message.format(value, allowed_value, allowed_value_specs)))
+                                    matches.append(RuleMatch(param_path, message.format(
+                                        value, allowed_value, allowed_value_specs)))
                         if default_value:
                             # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)
                             if str(default_value) not in allowed_value_specs:
                                 param_path = ['Parameters', value, 'Default']
                                 message = 'You must specify a valid Default value for {0} ({1}).\nValid values are {2}'
-                                matches.append(RuleMatch(param_path, message.format(value, default_value, allowed_value_specs)))
+                                matches.append(RuleMatch(param_path, message.format(
+                                    value, default_value, allowed_value_specs)))
 
         return matches
 
@@ -87,7 +96,8 @@
                             cfn.check_value(
                                 p_value, prop, p_path,
                                 check_ref=self.check_value_ref,
-                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),
+                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get(
+                                    'ValueTypes').get(value_type, {}),
                                 cfn=cfn, property_type=property_type, property_name=prop
                             )
                         )
@@ -98,7 +108,8 @@
         """Match for sub properties"""
         matches = list()
 
-        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})
+        specs = RESOURCE_SPECS.get(cfn.regions[0]).get(
+            'PropertyTypes').get(property_type, {}).get('Properties', {})
         property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)
         matches.extend(self.check(cfn, properties, specs, property_specs, path))
 
@@ -108,7 +119,8 @@
         """Check CloudFormation Properties"""
         matches = list()
 
-        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})
+        specs = RESOURCE_SPECS.get(cfn.regions[0]).get(
+            'ResourceTypes').get(resource_type, {}).get('Properties', {})
         resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)
         matches.extend(self.check(cfn, properties, specs, resource_specs, path))

{"golden_diff": "diff --git a/src/cfnlint/rules/parameters/AllowedValue.py b/src/cfnlint/rules/parameters/AllowedValue.py\n--- a/src/cfnlint/rules/parameters/AllowedValue.py\n+++ b/src/cfnlint/rules/parameters/AllowedValue.py\n@@ -40,12 +40,19 @@\n         \"\"\"Check Ref\"\"\"\n         matches = []\n \n+        cfn = kwargs.get('cfn')\n         if 'Fn::If' in path:\n-            self.logger.debug('Not able to guarentee that the default value hasn\\'t been conditioned out')\n+            self.logger.debug(\n+                'Not able to guarentee that the default value hasn\\'t been conditioned out')\n+            return matches\n+        if path[0] == 'Resources' and 'Condition' in cfn.template.get(\n+                path[0], {}).get(path[1]):\n+            self.logger.debug(\n+                'Not able to guarentee that the default value '\n+                'hasn\\'t been conditioned out')\n             return matches\n \n         allowed_value_specs = kwargs.get('value_specs', {}).get('AllowedValues', {})\n-        cfn = kwargs.get('cfn')\n \n         if allowed_value_specs:\n             if value in cfn.template.get('Parameters', {}):\n@@ -63,13 +70,15 @@\n                                 if str(allowed_value) not in allowed_value_specs:\n                                     param_path = ['Parameters', value, 'AllowedValues', index]\n                                     message = 'You must specify a valid allowed value for {0} ({1}).\\nValid values are {2}'\n-                                    matches.append(RuleMatch(param_path, message.format(value, allowed_value, allowed_value_specs)))\n+                                    matches.append(RuleMatch(param_path, message.format(\n+                                        value, allowed_value, allowed_value_specs)))\n                         if default_value:\n                             # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)\n                             if str(default_value) not in allowed_value_specs:\n                                 param_path = ['Parameters', value, 'Default']\n                                 message = 'You must specify a valid Default value for {0} ({1}).\\nValid values are {2}'\n-                                matches.append(RuleMatch(param_path, message.format(value, default_value, allowed_value_specs)))\n+                                matches.append(RuleMatch(param_path, message.format(\n+                                    value, default_value, allowed_value_specs)))\n \n         return matches\n \n@@ -87,7 +96,8 @@\n                             cfn.check_value(\n                                 p_value, prop, p_path,\n                                 check_ref=self.check_value_ref,\n-                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),\n+                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get(\n+                                    'ValueTypes').get(value_type, {}),\n                                 cfn=cfn, property_type=property_type, property_name=prop\n                             )\n                         )\n@@ -98,7 +108,8 @@\n         \"\"\"Match for sub properties\"\"\"\n         matches = list()\n \n-        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})\n+        specs = RESOURCE_SPECS.get(cfn.regions[0]).get(\n+            'PropertyTypes').get(property_type, {}).get('Properties', {})\n         property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)\n         matches.extend(self.check(cfn, properties, specs, property_specs, path))\n \n@@ -108,7 +119,8 @@\n         \"\"\"Check CloudFormation Properties\"\"\"\n         matches = list()\n \n-        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})\n+        specs = RESOURCE_SPECS.get(cfn.regions[0]).get(\n+            'ResourceTypes').get(resource_type, {}).get('Properties', {})\n         resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)\n         matches.extend(self.check(cfn, properties, specs, resource_specs, path))\n", "issue": "W2030 Default value required on conditionally included property\n*cfn-lint version: 0.21.3*\r\n\r\nCloudFormation provides the AWS::NoValue pseudo-parameter, which allows for a property to be included based on a given Condition. However, cfn-lint will still validate the potential value provided for the property, even if it will not actually be used in the deployment.\r\n\r\nExample template:\r\n\r\n```yaml\r\nParameters:\r\n  Retention:\r\n    Type: Number\r\n    Description: Retention in days for the log group (-1 for no retention)\r\n    Default: -1\r\nConditions:\r\n  IsRetention: \r\n    !Not [!Equals [!Ref 'Retention', '-1']]\r\nResources:\r\n  LogGroup:\r\n    Type: AWS::Logs::LogGroup\r\n    Properties:\r\n      LogGroupName: 'some-log-group'\r\n      RetentionInDays: !If [IsRetention, !Ref Retention, !Ref 'AWS::NoValue']\r\n```\r\n\r\nThis template allows the user to specify the retention on a log group, or use the number -1 if they wish to have unlimited retention. This is achieved via a Condition as well as an If block that conditionally includes the property.\r\n\r\nThis leads to the following linter output:\r\n\r\n```\r\ncfn-lint --template template.yaml\r\nW2030 You must specify a valid Default value for Retention (-1).   \r\nValid values are ['1', '3', '5', '7', '14', '30', '60', '90', '120', '150', '180', '365', '400', '545', '731', '1827', '3653']\r\ncloudformation/template.yaml:5:5\r\n```\r\n\r\nThis can of course be avoided by disabling this specific check in the template Metadata block. Unfortunately it cannot be disabled in the resource Metadata, as the validation error happens on the Parameter:\r\n\r\n```yaml\r\nMetadata:\r\n  cfn-lint:\r\n    config:\r\n      ignore_checks:\r\n        - W2030\r\n```\r\n\r\nThis might be a difficult situation to account for, since it would require the Condition to be evaluated to determine whether the property itself should even be checked.\n", "before_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport six\nfrom cfnlint.rules import CloudFormationLintRule\nfrom cfnlint.rules import RuleMatch\n\nfrom cfnlint.helpers import RESOURCE_SPECS\n\n\nclass AllowedValue(CloudFormationLintRule):\n    \"\"\"Check if parameters have a valid value\"\"\"\n    id = 'W2030'\n    shortdesc = 'Check if parameters have a valid value'\n    description = 'Check if parameters have a valid value in case of an enumator. The Parameter''s allowed values is based on the usages in property (Ref)'\n    source_url = 'https://github.com/aws-cloudformation/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedvalue'\n    tags = ['resources', 'property', 'allowed value']\n\n    def initialize(self, cfn):\n        \"\"\"Initialize the rule\"\"\"\n        for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes'):\n            self.resource_property_types.append(resource_type_spec)\n        for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):\n            self.resource_sub_property_types.append(property_type_spec)\n\n    def check_value_ref(self, value, path, **kwargs):\n        \"\"\"Check Ref\"\"\"\n        matches = []\n\n        if 'Fn::If' in path:\n            self.logger.debug('Not able to guarentee that the default value hasn\\'t been conditioned out')\n            return matches\n\n        allowed_value_specs = kwargs.get('value_specs', {}).get('AllowedValues', {})\n        cfn = kwargs.get('cfn')\n\n        if allowed_value_specs:\n            if value in cfn.template.get('Parameters', {}):\n                param = cfn.template.get('Parameters').get(value, {})\n                parameter_values = param.get('AllowedValues')\n                default_value = param.get('Default')\n                parameter_type = param.get('Type')\n                if isinstance(parameter_type, six.string_types):\n                    if ((not parameter_type.startswith('List<')) and\n                            (not parameter_type.startswith('AWS::SSM::Parameter::Value<')) and\n                            parameter_type not in ['CommaDelimitedList', 'List<String>']):\n                        # Check Allowed Values\n                        if parameter_values:\n                            for index, allowed_value in enumerate(parameter_values):\n                                if str(allowed_value) not in allowed_value_specs:\n                                    param_path = ['Parameters', value, 'AllowedValues', index]\n                                    message = 'You must specify a valid allowed value for {0} ({1}).\\nValid values are {2}'\n                                    matches.append(RuleMatch(param_path, message.format(value, allowed_value, allowed_value_specs)))\n                        if default_value:\n                            # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)\n                            if str(default_value) not in allowed_value_specs:\n                                param_path = ['Parameters', value, 'Default']\n                                message = 'You must specify a valid Default value for {0} ({1}).\\nValid values are {2}'\n                                matches.append(RuleMatch(param_path, message.format(value, default_value, allowed_value_specs)))\n\n        return matches\n\n    def check(self, cfn, properties, value_specs, property_specs, path):\n        \"\"\"Check itself\"\"\"\n        matches = list()\n        for p_value, p_path in properties.items_safe(path[:]):\n            for prop in p_value:\n                if prop in value_specs:\n                    value = value_specs.get(prop).get('Value', {})\n                    if value:\n                        value_type = value.get('ValueType', '')\n                        property_type = property_specs.get('Properties').get(prop).get('Type')\n                        matches.extend(\n                            cfn.check_value(\n                                p_value, prop, p_path,\n                                check_ref=self.check_value_ref,\n                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),\n                                cfn=cfn, property_type=property_type, property_name=prop\n                            )\n                        )\n\n        return matches\n\n    def match_resource_sub_properties(self, properties, property_type, path, cfn):\n        \"\"\"Match for sub properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})\n        property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)\n        matches.extend(self.check(cfn, properties, specs, property_specs, path))\n\n        return matches\n\n    def match_resource_properties(self, properties, resource_type, path, cfn):\n        \"\"\"Check CloudFormation Properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})\n        resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)\n        matches.extend(self.check(cfn, properties, specs, resource_specs, path))\n\n        return matches\n", "path": "src/cfnlint/rules/parameters/AllowedValue.py"}], "after_files": [{"content": "\"\"\"\n  Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.\n\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this\n  software and associated documentation files (the \"Software\"), to deal in the Software\n  without restriction, including without limitation the rights to use, copy, modify,\n  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to\n  permit persons to whom the Software is furnished to do so.\n\n  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,\n  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A\n  PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\n  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\"\"\"\nimport six\nfrom cfnlint.rules import CloudFormationLintRule\nfrom cfnlint.rules import RuleMatch\n\nfrom cfnlint.helpers import RESOURCE_SPECS\n\n\nclass AllowedValue(CloudFormationLintRule):\n    \"\"\"Check if parameters have a valid value\"\"\"\n    id = 'W2030'\n    shortdesc = 'Check if parameters have a valid value'\n    description = 'Check if parameters have a valid value in case of an enumator. The Parameter''s allowed values is based on the usages in property (Ref)'\n    source_url = 'https://github.com/aws-cloudformation/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedvalue'\n    tags = ['resources', 'property', 'allowed value']\n\n    def initialize(self, cfn):\n        \"\"\"Initialize the rule\"\"\"\n        for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes'):\n            self.resource_property_types.append(resource_type_spec)\n        for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):\n            self.resource_sub_property_types.append(property_type_spec)\n\n    def check_value_ref(self, value, path, **kwargs):\n        \"\"\"Check Ref\"\"\"\n        matches = []\n\n        cfn = kwargs.get('cfn')\n        if 'Fn::If' in path:\n            self.logger.debug(\n                'Not able to guarentee that the default value hasn\\'t been conditioned out')\n            return matches\n        if path[0] == 'Resources' and 'Condition' in cfn.template.get(\n                path[0], {}).get(path[1]):\n            self.logger.debug(\n                'Not able to guarentee that the default value '\n                'hasn\\'t been conditioned out')\n            return matches\n\n        allowed_value_specs = kwargs.get('value_specs', {}).get('AllowedValues', {})\n\n        if allowed_value_specs:\n            if value in cfn.template.get('Parameters', {}):\n                param = cfn.template.get('Parameters').get(value, {})\n                parameter_values = param.get('AllowedValues')\n                default_value = param.get('Default')\n                parameter_type = param.get('Type')\n                if isinstance(parameter_type, six.string_types):\n                    if ((not parameter_type.startswith('List<')) and\n                            (not parameter_type.startswith('AWS::SSM::Parameter::Value<')) and\n                            parameter_type not in ['CommaDelimitedList', 'List<String>']):\n                        # Check Allowed Values\n                        if parameter_values:\n                            for index, allowed_value in enumerate(parameter_values):\n                                if str(allowed_value) not in allowed_value_specs:\n                                    param_path = ['Parameters', value, 'AllowedValues', index]\n                                    message = 'You must specify a valid allowed value for {0} ({1}).\\nValid values are {2}'\n                                    matches.append(RuleMatch(param_path, message.format(\n                                        value, allowed_value, allowed_value_specs)))\n                        if default_value:\n                            # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)\n                            if str(default_value) not in allowed_value_specs:\n                                param_path = ['Parameters', value, 'Default']\n                                message = 'You must specify a valid Default value for {0} ({1}).\\nValid values are {2}'\n                                matches.append(RuleMatch(param_path, message.format(\n                                    value, default_value, allowed_value_specs)))\n\n        return matches\n\n    def check(self, cfn, properties, value_specs, property_specs, path):\n        \"\"\"Check itself\"\"\"\n        matches = list()\n        for p_value, p_path in properties.items_safe(path[:]):\n            for prop in p_value:\n                if prop in value_specs:\n                    value = value_specs.get(prop).get('Value', {})\n                    if value:\n                        value_type = value.get('ValueType', '')\n                        property_type = property_specs.get('Properties').get(prop).get('Type')\n                        matches.extend(\n                            cfn.check_value(\n                                p_value, prop, p_path,\n                                check_ref=self.check_value_ref,\n                                value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get(\n                                    'ValueTypes').get(value_type, {}),\n                                cfn=cfn, property_type=property_type, property_name=prop\n                            )\n                        )\n\n        return matches\n\n    def match_resource_sub_properties(self, properties, property_type, path, cfn):\n        \"\"\"Match for sub properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get(\n            'PropertyTypes').get(property_type, {}).get('Properties', {})\n        property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)\n        matches.extend(self.check(cfn, properties, specs, property_specs, path))\n\n        return matches\n\n    def match_resource_properties(self, properties, resource_type, path, cfn):\n        \"\"\"Check CloudFormation Properties\"\"\"\n        matches = list()\n\n        specs = RESOURCE_SPECS.get(cfn.regions[0]).get(\n            'ResourceTypes').get(resource_type, {}).get('Properties', {})\n        resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)\n        matches.extend(self.check(cfn, properties, specs, resource_specs, path))\n\n        return matches\n", "path": "src/cfnlint/rules/parameters/AllowedValue.py"}]}