Repository: aws-cloudformation/cfn-lint

Issue:
W2030 - Number expected as String 
cfn-lint 0.19.0

W2030 - Number expected as String

The following warning has started to appear in the latest version:
W2030 You must specify a valid allowed value for NAME_OF_THE_PARAMETER

Template example:
```
  LogsRetentionLength:
    AllowedValues:
      - 1
      - 3
    Default: 1
    Description: The retention length of the logs.
    Type: Number
```

```
  LogGroup:
    Type: AWS::Logs::LogGroup
    Properties:
      RetentionInDays: !Ref LogsRetentionLength
      LogGroupName: '/name'
```

Error:
```
W2030 You must specify a valid allowed value for LogsRetentionLength (1).
Valid values are ['1', '3', '5', '7', '14', '30', '60', '90', '120', '150', '180', '365', '400', '545', '731', '1827', '3653']
W2030 You must specify a valid allowed value for LogsRetentionLength (3).
Valid values are ['1', '3', '5', '7', '14', '30', '60', '90', '120', '150', '180', '365', '400', '545', '731', '1827', '3653']
W2030 You must specify a valid Default value for LogsRetentionLength (1).
Valid values are ['1', '3', '5', '7', '14', '30', '60', '90', '120', '150', '180', '365', '400', '545', '731', '1827', '3653']
```

Changing the templates as follow fixes the issue but it's incorrect:

```
  LogsRetentionLength:
    AllowedValues:
      - '1'
      - '3'
    Default: '1'
    Description: The retention length of the logs.
    Type: Number
```


Discussion:
Looking into this should have something to you shortly. 

Resolving patch:
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
@@ -56,13 +56,13 @@ def check_value_ref(self, value, **kwargs):
                         # Check Allowed Values
                         if parameter_values:
                             for index, allowed_value in enumerate(parameter_values):
-                                if allowed_value not in allowed_value_specs:
+                                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)))
-                        elif default_value:
+                        if 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:
+                            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)))


Test patch:
diff --git a/test/fixtures/templates/good/resources/properties/allowed_values.yaml b/test/fixtures/templates/good/resources/properties/allowed_values.yaml
--- a/test/fixtures/templates/good/resources/properties/allowed_values.yaml
+++ b/test/fixtures/templates/good/resources/properties/allowed_values.yaml
@@ -21,7 +21,19 @@ Parameters:
     Default: /Demo/DemoInstanceType # Recommend t3.nano
     Description: EC2 instance type to use to create the collector host
     Type: AWS::SSM::Parameter::Value<String>
+  LogsRetentionLength:
+    AllowedValues:
+      - 1
+      - 3
+    Default: 1
+    Description: The retention length of the logs.
+    Type: Number
 Resources:
+  LogGroup:
+    Type: AWS::Logs::LogGroup
+    Properties:
+      RetentionInDays: !Ref LogsRetentionLength
+      LogGroupName: '/name'
   AmazonMQBroker:
     Type: "AWS::AmazonMQ::Broker"
     Properties:
diff --git a/test/rules/parameters/test_allowed_value.py b/test/rules/parameters/test_allowed_value.py
--- a/test/rules/parameters/test_allowed_value.py
+++ b/test/rules/parameters/test_allowed_value.py
@@ -34,4 +34,4 @@ def test_file_positive(self):
 
     def test_file_negative(self):
         """Test failure"""
-        self.helper_file_negative('test/fixtures/templates/bad/resources/properties/allowed_values.yaml', 1)
+        self.helper_file_negative('test/fixtures/templates/bad/resources/properties/allowed_values.yaml', 2)