Repository: aws-cloudformation/cfn-lint

Issue:
E3012 Property should be of type Json - incorrectly flagging official examples
*cfn-lint version:*
0.51.0
*Description of issue.*
After upgrading to 0.51.0 today, we are now seeing new lint issues. Specifically `E3012 Property should be of type Json` on the parameters section of `AWS::SSM::Association`

Even the example from the official docs is flagged by cfn-lint now. 
e.g.
```yaml
Resources:
  SpecificInstanceIdAssociation:
    Type: AWS::SSM::Association
    Properties:
      Name: AWS-RunShellScript
      Targets:
      - Key: InstanceIds
        Values:
        - i-1234567890abcdef0
      Parameters:
        commands:
        - ls
        workingDirectory:
        - "/"
      WaitForSuccessTimeoutSeconds: 300
```

`E3012 Property should be of type Json at Resources/SpecificInstanceIdAssociation/Properties/Parameters/commands
test.yaml:11:9`
`E3012 Property should be of type Json at Resources/SpecificInstanceIdAssociation/Properties/Parameters/workingDirectory
test.yaml:13:9`




Discussion:
See pinned issue https://github.com/aws-cloudformation/cfn-lint/issues/547
@PatMyron This appears to be more than an issue of strict typing. Templates that are accepted by cloudformation are failing the linting checks.

For example, this template deploys without error
```yaml
AWSTemplateFormatVersion: '2010-09-09'
Resources:
  SSMGetInventoryAssociation:
      Type: AWS::SSM::Association
      Properties:
        Name: AWS-GatherSoftwareInventory
        AssociationName: gather-inventory
        Parameters:
          applications:
          - Enabled
          awsComponents:
          - Enabled
          customInventory:
          - Enabled
          instanceDetailedInformation:
          - Enabled
          networkConfig:
          - Enabled
          services:
          - Enabled
          windowsRoles:
          - Enabled
          windowsUpdates:
          - Enabled
        ScheduleExpression: rate(3 days)
        Targets:
        - Key: InstanceIds
          Values:
          - '*'
 ```
But cfn-lint produces
```E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/applications
test-assoc.yaml:9:11

E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/awsComponents
test-assoc.yaml:11:11

E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/customInventory
test-assoc.yaml:13:11

E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/instanceDetailedInformation
test-assoc.yaml:15:11

E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/networkConfig
test-assoc.yaml:17:11

E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/services
test-assoc.yaml:19:11

E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/windowsRoles
test-assoc.yaml:21:11

E3012 Property should be of type Json at Resources/SSMGetInventoryAssociation/Properties/Parameters/windowsUpdates
test-assoc.yaml:23:11```
looking into this
Not sure what started the issue as that rule didn't change but a list is still valid json and we should consider it so.  Fixing the issue inside E3012
@kddejong  The changes in the cloudspecs in https://github.com/aws-cloudformation/cfn-lint/pull/2039/ line up with when we started seeing errors on our end.
> Not sure what started the issue as that rule didn't change but a list is still valid json and we should consider it so. Fixing the issue inside E3012

think @omkhegde [changed resource specification format recently](https://code.amazon.com/r/CR-51080450) since [`List` isn't a documented primitive type](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cfn-resource-specification-format.html#cfn-resource-specification-format-propertytypes)
Thanks for the quick fix all - really appreciate it. 
Hello.  I am a bit new and am seeing this on the following data:

```
[E3002: Resource properties are valid] (Property should be of type Json not List at Resources/ResourceName/Properties/Tags)
```

the tags in question:

```yaml
Resources:
  ResourceName:
    Properties:
      Description: Human Readable Description
      Name: /path/of/param
      Tags:
      - {Key: ENVIRONMENT, Value: test}
      - {Key: RESOURCE_NAME, Value: broker_dns_addresses}
      - {Key: STACK_NAME, Value: example-service}
      Type: StringList
      Value: ValueOfParam
```

Could you hint me if the problem lies on my end?  Thank you!
@evilensky that can be the same template? Maybe a spacing issue.
That template gives me
```
E3001 Type not defined for resource ResourceName
local/issue/2063-1.yaml:2:3
```

I'm guessing you meant
```
Resources:
  ResourceName:
    Type: AWS::SSM::Parameter
    Properties:
      Description: Human Readable Description
      Name: /path/of/param
      Tags:
      - {Key: ENVIRONMENT, Value: test}
      - {Key: RESOURCE_NAME, Value: broker_dns_addresses}
      - {Key: STACK_NAME, Value: example-service}
      Type: StringList
      Value: ValueOfParam
```

Putting in another fix for that

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
@@ -36,7 +36,7 @@ def primitivetypecheck(self, value, primtype, proppath):
         """
 
         matches = []
-        if isinstance(value, list) or value == {'Ref': 'AWS::NotificationARNs'}:
+        if (isinstance(value, list) and primtype != 'Json') or value == {'Ref': 'AWS::NotificationARNs'}:
             message = 'Property should be of type %s not List at %s' % (
                 primtype, '/'.join(map(str, proppath)))
             matches.append(RuleMatch(proppath, message))


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
@@ -740,3 +740,14 @@ Resources:
               Status: Enabled
             
         - - !Ref "AWS::NoValue"
+  SSMParameterJsonList:
+    Type: AWS::SSM::Parameter
+    Properties:
+      Description: Human Readable Description
+      Name: /path/of/param
+      Tags:
+      - {Key: ENVIRONMENT, Value: test}
+      - {Key: RESOURCE_NAME, Value: broker_dns_addresses}
+      - {Key: STACK_NAME, Value: example-service}
+      Type: StringList
+      Value: ValueOfParam