We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Getting 'W2030:You must specify a valid Default value' in 0.17.1
*cfn-lint version: (`cfn-lint --version`)*
`cfn-lint 0.17.1`

*Description of issue.*
```
[cfn-lint] W2030:You must specify a valid Default value for DemoInstanceType (/Demo/DemoInstanceType).
Valid values are ['a1.2xlarge', 'a1.4xlarge', 'a1.large', 'a1.medium', 'a1.xlarge', 'c1.medium', 'c1.xlarge', 'c3.2xlarge', 'c3.4xlarge', 'c3.8xlarge', 'c3.large', 'c3.xlarge', 'c4.2xlarge', 'c4.4xlarge', 'c4.8xlarge', 'c4.large', 'c4.xlarge', 'c5.18xlarge', 'c5.2xlarge', 'c5.4xlarge', 'c5.9xlarge', 'c5.large', 'c5.xlarge', 'c5d.18xlarge', 'c5d.2xlarge', 'c5d.4xlarge', 'c5d.9xlarge', 'c5d.large', 'c5d.xlarge', 'c5n.18xlarge', 'c5n.2xlarge', 'c5n.4xlarge', 'c5n.9xlarge', 'c5n.large', 'c5n.xlarge', 'cc2.8xlarge', 'cr1.8xlarge', 'd2.2xlarge', 'd2.4xlarge', 'd2.8xlarge', 'd2.xlarge', 'f1.16xlarge', 'f1.2xlarge', 'f1.4xlarge', 'g2.2xlarge', 'g2.8xlarge', 'g3.16xlarge', 'g3.4xlarge', 'g3.8xlarge', 'g3s.xlarge', 'h1.16xlarge', 'h1.2xlarge', 'h1.4xlarge', 'h1.8xlarge', 'hs1.8xlarge', 'i2.2xlarge', 'i2.4xlarge', 'i2.8xlarge', 'i2.xlarge', 'i3.16xlarge', 'i3.2xlarge', 'i3.4xlarge', 'i3.8xlarge', 'i3.large', 'i3.xlarge', 'm1.large', 'm1.medium', 'm1.small', 'm1.xlarge', 'm2.2xlarge', 'm2.4xlarge', 'm2.xlarge', 'm3.2xlarge', 'm3.large', 'm3.medium', 'm3.xlarge', 'm4.10xlarge', 'm4.16xlarge', 'm4.2xlarge', 'm4.4xlarge', 'm4.large', 'm4.xlarge', 'm5.12xlarge', 'm5.24xlarge', 'm5.2xlarge', 'm5.4xlarge', 'm5.large', 'm5.metal', 'm5.xlarge', 'm5a.12xlarge', 'm5a.24xlarge', 'm5a.2xlarge', 'm5a.4xlarge', 'm5a.large', 'm5a.xlarge', 'm5ad.12xlarge', 'm5ad.24xlarge', 'm5ad.2xlarge', 'm5ad.4xlarge', 'm5ad.large', 'm5ad.xlarge', 'm5d.12xlarge', 'm5d.24xlarge', 'm5d.2xlarge', 'm5d.4xlarge', 'm5d.large', 'm5d.metal', 'm5d.xlarge', 'p2.16xlarge', 'p2.8xlarge', 'p2.xlarge', 'p3.16xlarge', 'p3.2xlarge', 'p3.8xlarge', 'p3dn.24xlarge', 'r3.2xlarge', 'r3.4xlarge', 'r3.8xlarge', 'r3.large', 'r3.xlarge', 'r4.16xlarge', 'r4.2xlarge', 'r4.4xlarge', 'r4.8xlarge', 'r4.large', 'r4.xlarge', 'r5.12xlarge', 'r5.24xlarge', 'r5.2xlarge', 'r5.4xlarge', 'r5.large', 'r5.xlarge', 'r5a.12xlarge', 'r5a.24xlarge', 'r5a.2xlarge', 'r5a.4xlarge', 'r5a.large', 'r5a.xlarge', 'r5ad.12xlarge', 'r5ad.24xlarge', 'r5ad.2xlarge', 'r5ad.4xlarge', 'r5ad.large', 'r5ad.xlarge', 'r5d.12xlarge', 'r5d.24xlarge', 'r5d.2xlarge', 'r5d.4xlarge', 'r5d.large', 'r5d.xlarge', 't1.micro', 't2.2xlarge', 't2.large', 't2.medium', 't2.micro', 't2.nano', 't2.small', 't2.xlarge', 't3.2xlarge', 't3.large', 't3.medium', 't3.micro', 't3.nano', 't3.small', 't3.xlarge', 'x1.16xlarge', 'x1.32xlarge', 'x1e.16xlarge', 'x1e.2xlarge', 'x1e.32xlarge', 'x1e.4xlarge', 'x1e.8xlarge', 'x1e.xlarge', 'z1d.12xlarge', 'z1d.2xlarge', 'z1d.3xlarge', 'z1d.6xlarge', 'z1d.large', 'z1d.xlarge']
```

The CloudFormation parameter is :
```
  DemoInstanceType:
    Default: /Demo/DemoInstanceType # Recommend t3.nano
    Description: EC2 instance type to use to create the collector host
    Type: AWS::SSM::Parameter::Value<String>
```

The value of the SSM parameter is `t3.nano`

I have an older project using the same pattern and the virtual environment still has cfn-lint version 0.12.0. It's not raising this complaint. I verified by updating to latest (0.17.1) and the problem cropped up. When I downgraded back to 0.12.0, the problem went away.

--- 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 from cfnlint import CloudFormationLintRule
18 from cfnlint import RuleMatch
19 
20 from cfnlint.helpers import RESOURCE_SPECS
21 
22 
23 class AllowedValue(CloudFormationLintRule):
24     """Check if parameters have a valid value"""
25     id = 'W2030'
26     shortdesc = 'Check if parameters have a valid value'
27     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)'
28     source_url = 'https://github.com/aws-cloudformation/cfn-python-lint/blob/master/docs/cfn-resource-specification.md#allowedvalue'
29     tags = ['resources', 'property', 'allowed value']
30 
31     def initialize(self, cfn):
32         """Initialize the rule"""
33         for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes'):
34             self.resource_property_types.append(resource_type_spec)
35         for property_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes'):
36             self.resource_sub_property_types.append(property_type_spec)
37 
38     def check_value_ref(self, value, **kwargs):
39         """Check Ref"""
40         matches = []
41 
42         allowed_value_specs = kwargs.get('value_specs', {}).get('AllowedValues', {})
43         cfn = kwargs.get('cfn')
44 
45         if allowed_value_specs:
46             if value in cfn.template.get('Parameters', {}):
47                 param = cfn.template.get('Parameters').get(value, {})
48                 parameter_values = param.get('AllowedValues')
49                 default_value = param.get('Default')
50 
51                 # Check Allowed Values
52                 if parameter_values:
53                     for index, allowed_value in enumerate(parameter_values):
54                         if allowed_value not in allowed_value_specs:
55                             param_path = ['Parameters', value, 'AllowedValues', index]
56                             message = 'You must specify a valid allowed value for {0} ({1}).\nValid values are {2}'
57                             matches.append(RuleMatch(param_path, message.format(value, allowed_value, allowed_value_specs)))
58                 elif default_value:
59                     # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)
60                     if default_value not in allowed_value_specs:
61                         param_path = ['Parameters', value, 'Default']
62                         message = 'You must specify a valid Default value for {0} ({1}).\nValid values are {2}'
63                         matches.append(RuleMatch(param_path, message.format(value, default_value, allowed_value_specs)))
64 
65         return matches
66 
67     def check(self, cfn, properties, value_specs, property_specs, path):
68         """Check itself"""
69         matches = list()
70         for p_value, p_path in properties.items_safe(path[:]):
71             for prop in p_value:
72                 if prop in value_specs:
73                     value = value_specs.get(prop).get('Value', {})
74                     if value:
75                         value_type = value.get('ValueType', '')
76                         property_type = property_specs.get('Properties').get(prop).get('Type')
77                         matches.extend(
78                             cfn.check_value(
79                                 p_value, prop, p_path,
80                                 check_ref=self.check_value_ref,
81                                 value_specs=RESOURCE_SPECS.get(cfn.regions[0]).get('ValueTypes').get(value_type, {}),
82                                 cfn=cfn, property_type=property_type, property_name=prop
83                             )
84                         )
85 
86         return matches
87 
88     def match_resource_sub_properties(self, properties, property_type, path, cfn):
89         """Match for sub properties"""
90         matches = list()
91 
92         specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type, {}).get('Properties', {})
93         property_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('PropertyTypes').get(property_type)
94         matches.extend(self.check(cfn, properties, specs, property_specs, path))
95 
96         return matches
97 
98     def match_resource_properties(self, properties, resource_type, path, cfn):
99         """Check CloudFormation Properties"""
100         matches = list()
101 
102         specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type, {}).get('Properties', {})
103         resource_specs = RESOURCE_SPECS.get(cfn.regions[0]).get('ResourceTypes').get(resource_type)
104         matches.extend(self.check(cfn, properties, specs, resource_specs, path))
105 
106         return matches
107
```
--- 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
@@ -14,6 +14,7 @@
   OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 """
+import six
 from cfnlint import CloudFormationLintRule
 from cfnlint import RuleMatch
 
@@ -47,20 +48,24 @@
                 param = cfn.template.get('Parameters').get(value, {})
                 parameter_values = param.get('AllowedValues')
                 default_value = param.get('Default')
-
-                # Check Allowed Values
-                if parameter_values:
-                    for index, allowed_value in enumerate(parameter_values):
-                        if 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)))
-                elif default_value:
-                    # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)
-                    if 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)))
+                parameter_type = param.get('Type')
+                if isinstance(parameter_type, six.string_types):
+                    if ((not parameter_type.startswith('List<')) and
+                            (not parameter_type.startswith('AWS::SSM::Parameter::Value<')) and
+                            parameter_type not in ['CommaDelimitedList']):
+                        # Check Allowed Values
+                        if parameter_values:
+                            for index, allowed_value in enumerate(parameter_values):
+                                if 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)))
+                        elif default_value:
+                            # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)
+                            if 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)))
 
         return matches

{"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@@ -14,6 +14,7 @@\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 \"\"\"\n+import six\n from cfnlint import CloudFormationLintRule\n from cfnlint import RuleMatch\n \n@@ -47,20 +48,24 @@\n                 param = cfn.template.get('Parameters').get(value, {})\n                 parameter_values = param.get('AllowedValues')\n                 default_value = param.get('Default')\n-\n-                # Check Allowed Values\n-                if parameter_values:\n-                    for index, allowed_value in enumerate(parameter_values):\n-                        if 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-                elif default_value:\n-                    # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)\n-                    if 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+                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']):\n+                        # Check Allowed Values\n+                        if parameter_values:\n+                            for index, allowed_value in enumerate(parameter_values):\n+                                if 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+                        elif default_value:\n+                            # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)\n+                            if 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", "issue": "Getting 'W2030:You must specify a valid Default value' in 0.17.1\n*cfn-lint version: (`cfn-lint --version`)*\r\n`cfn-lint 0.17.1`\r\n\r\n*Description of issue.*\r\n```\r\n[cfn-lint] W2030:You must specify a valid Default value for DemoInstanceType (/Demo/DemoInstanceType).\r\nValid values are ['a1.2xlarge', 'a1.4xlarge', 'a1.large', 'a1.medium', 'a1.xlarge', 'c1.medium', 'c1.xlarge', 'c3.2xlarge', 'c3.4xlarge', 'c3.8xlarge', 'c3.large', 'c3.xlarge', 'c4.2xlarge', 'c4.4xlarge', 'c4.8xlarge', 'c4.large', 'c4.xlarge', 'c5.18xlarge', 'c5.2xlarge', 'c5.4xlarge', 'c5.9xlarge', 'c5.large', 'c5.xlarge', 'c5d.18xlarge', 'c5d.2xlarge', 'c5d.4xlarge', 'c5d.9xlarge', 'c5d.large', 'c5d.xlarge', 'c5n.18xlarge', 'c5n.2xlarge', 'c5n.4xlarge', 'c5n.9xlarge', 'c5n.large', 'c5n.xlarge', 'cc2.8xlarge', 'cr1.8xlarge', 'd2.2xlarge', 'd2.4xlarge', 'd2.8xlarge', 'd2.xlarge', 'f1.16xlarge', 'f1.2xlarge', 'f1.4xlarge', 'g2.2xlarge', 'g2.8xlarge', 'g3.16xlarge', 'g3.4xlarge', 'g3.8xlarge', 'g3s.xlarge', 'h1.16xlarge', 'h1.2xlarge', 'h1.4xlarge', 'h1.8xlarge', 'hs1.8xlarge', 'i2.2xlarge', 'i2.4xlarge', 'i2.8xlarge', 'i2.xlarge', 'i3.16xlarge', 'i3.2xlarge', 'i3.4xlarge', 'i3.8xlarge', 'i3.large', 'i3.xlarge', 'm1.large', 'm1.medium', 'm1.small', 'm1.xlarge', 'm2.2xlarge', 'm2.4xlarge', 'm2.xlarge', 'm3.2xlarge', 'm3.large', 'm3.medium', 'm3.xlarge', 'm4.10xlarge', 'm4.16xlarge', 'm4.2xlarge', 'm4.4xlarge', 'm4.large', 'm4.xlarge', 'm5.12xlarge', 'm5.24xlarge', 'm5.2xlarge', 'm5.4xlarge', 'm5.large', 'm5.metal', 'm5.xlarge', 'm5a.12xlarge', 'm5a.24xlarge', 'm5a.2xlarge', 'm5a.4xlarge', 'm5a.large', 'm5a.xlarge', 'm5ad.12xlarge', 'm5ad.24xlarge', 'm5ad.2xlarge', 'm5ad.4xlarge', 'm5ad.large', 'm5ad.xlarge', 'm5d.12xlarge', 'm5d.24xlarge', 'm5d.2xlarge', 'm5d.4xlarge', 'm5d.large', 'm5d.metal', 'm5d.xlarge', 'p2.16xlarge', 'p2.8xlarge', 'p2.xlarge', 'p3.16xlarge', 'p3.2xlarge', 'p3.8xlarge', 'p3dn.24xlarge', 'r3.2xlarge', 'r3.4xlarge', 'r3.8xlarge', 'r3.large', 'r3.xlarge', 'r4.16xlarge', 'r4.2xlarge', 'r4.4xlarge', 'r4.8xlarge', 'r4.large', 'r4.xlarge', 'r5.12xlarge', 'r5.24xlarge', 'r5.2xlarge', 'r5.4xlarge', 'r5.large', 'r5.xlarge', 'r5a.12xlarge', 'r5a.24xlarge', 'r5a.2xlarge', 'r5a.4xlarge', 'r5a.large', 'r5a.xlarge', 'r5ad.12xlarge', 'r5ad.24xlarge', 'r5ad.2xlarge', 'r5ad.4xlarge', 'r5ad.large', 'r5ad.xlarge', 'r5d.12xlarge', 'r5d.24xlarge', 'r5d.2xlarge', 'r5d.4xlarge', 'r5d.large', 'r5d.xlarge', 't1.micro', 't2.2xlarge', 't2.large', 't2.medium', 't2.micro', 't2.nano', 't2.small', 't2.xlarge', 't3.2xlarge', 't3.large', 't3.medium', 't3.micro', 't3.nano', 't3.small', 't3.xlarge', 'x1.16xlarge', 'x1.32xlarge', 'x1e.16xlarge', 'x1e.2xlarge', 'x1e.32xlarge', 'x1e.4xlarge', 'x1e.8xlarge', 'x1e.xlarge', 'z1d.12xlarge', 'z1d.2xlarge', 'z1d.3xlarge', 'z1d.6xlarge', 'z1d.large', 'z1d.xlarge']\r\n```\r\n\r\nThe CloudFormation parameter is :\r\n```\r\n  DemoInstanceType:\r\n    Default: /Demo/DemoInstanceType # Recommend t3.nano\r\n    Description: EC2 instance type to use to create the collector host\r\n    Type: AWS::SSM::Parameter::Value<String>\r\n```\r\n\r\nThe value of the SSM parameter is `t3.nano`\r\n\r\nI have an older project using the same pattern and the virtual environment still has cfn-lint version 0.12.0. It's not raising this complaint. I verified by updating to latest (0.17.1) and the problem cropped up. When I downgraded back to 0.12.0, the problem went away.\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\"\"\"\nfrom cfnlint import CloudFormationLintRule\nfrom cfnlint 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, **kwargs):\n        \"\"\"Check Ref\"\"\"\n        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\n                # Check Allowed Values\n                if parameter_values:\n                    for index, allowed_value in enumerate(parameter_values):\n                        if 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                elif default_value:\n                    # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)\n                    if 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 import CloudFormationLintRule\nfrom cfnlint 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, **kwargs):\n        \"\"\"Check Ref\"\"\"\n        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']):\n                        # Check Allowed Values\n                        if parameter_values:\n                            for index, allowed_value in enumerate(parameter_values):\n                                if 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                        elif default_value:\n                            # Check Default, only if no allowed Values are specified in the parameter (that's covered by E2015)\n                            if 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"}]}