Repository: aws-cloudformation/cfn-lint

Issue:
"Property ... should be of type List or Parameter", when using a CommaDelimitedList
*cfn-lint version: (`cfn-lint --version`)*

`cfn-lint 0.3.5`

*Description of issue.*

Our CloudFormation template contains a `CommaDelimitedList` parameter:

    "Aliases" : {
        "Type": "CommaDelimitedList",
        "Default": "foo.com, bar.com"
    },

We reference this parameter under `Aliases` in our CloudFront distribution. The `Aliases` key [accepts a list of string values](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cloudfront-distribution-distributionconfig.html#cfn-cloudfront-distribution-distributionconfig-aliases) - which our `CommaDelimitedList` [provides](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/parameters-section-structure.html) - and the CloudFormation console correctly processes the template:

    "Distribution" : {
        "Type" : "AWS::CloudFront::Distribution",
        "Properties" : {
            "DistributionConfig" : {
                "Aliases" : { "Ref" : "Aliases" },
                ...
            }
        }
    }

However `cfn-lint` flags this as an error:

`E3002 Property Aliases should be of type List or Parameter should be a list for resource Distribution`

If we wrap the reference in a list, we can get a pass from `cfn-lint`:

    "Distribution" : {
        "Type" : "AWS::CloudFront::Distribution",
        "Properties" : {
            "DistributionConfig" : {
                "Aliases" : [
                    { "Ref" : "Aliases" }
                ]
                ...
            }
        }
    }

However that property is now evaluating to a list of lists:

    [ [ "foo.com", "bar.com" ] ]

This is an incorrect parameter and causes the CloudFormation console to fail with `Value of property Aliases must be of type List of String.`

It seems like `cfn-lint` may be interpreting the `CommaDelimitedList` type incorrectly? Possibly as a string, rather than a list of strings? Let me know if I can provide any more detail. 


Discussion:
Thanks for reporting this.  I'll try take a look tonight and get back to you.

Resolving patch:
diff --git a/src/cfnlint/rules/resources/properties/Properties.py b/src/cfnlint/rules/resources/properties/Properties.py
--- a/src/cfnlint/rules/resources/properties/Properties.py
+++ b/src/cfnlint/rules/resources/properties/Properties.py
@@ -197,8 +197,9 @@ def propertycheck(self, text, proptype, parenttype, resourcename, path, root):
                                 if 'Ref' in text[prop]:
                                     ref = text[prop]['Ref']
                                     if ref in parameternames:
-                                        if 'Type' in self.cfn.template['Parameters'][ref]:
-                                            if not self.cfn.template['Parameters'][ref]['Type'].startswith('List<'):
+                                        param_type = self.cfn.template['Parameters'][ref]['Type']
+                                        if param_type:
+                                            if not param_type.startswith('List<') and not param_type == 'CommaDelimitedList':
                                                 message = 'Property {0} should be of type List or Parameter should ' \
                                                           'be a list for resource {1}'
                                                 matches.append(


Test patch:
diff --git a/test/fixtures/templates/good/resource_properties.yaml b/test/fixtures/templates/good/resource_properties.yaml
--- a/test/fixtures/templates/good/resource_properties.yaml
+++ b/test/fixtures/templates/good/resource_properties.yaml
@@ -297,6 +297,9 @@ Parameters:
     Type: String
   ParamInstanceSecurityGroup:
     Type: List<AWS::EC2::SecurityGroup::Id>
+  Aliases:
+    Type: "CommaDelimitedList"
+    Default: "foo.com, bar.com"
 Conditions:
   HasSingleClusterInstance: !Equals [!Ref 'AWS::Region', 'us-east-1']
 Resources:
@@ -590,3 +593,9 @@ Resources:
           KeyType: HASH
         - AttributeName: !Ref SortKeyName
           KeyType: RANGE
+  Distribution:
+    Type: "AWS::CloudFront::Distribution"
+    Properties:
+      DistributionConfig:
+        Aliases: !Ref Aliases
+        Enabled: True