aws-cloudformation / cloudformation-template-schema

Inline syntax validation, documentation links and autocompletion for your CloudFormation templates.
Apache License 2.0
141 stars 24 forks source link

Schema is invalid, and outdated. #72

Open techzilla opened 7 months ago

techzilla commented 7 months ago

Validing https://s3.us-west-2.amazonaws.com/amazon-eks/cloudformation/2020-10-29/amazon-eks-vpc-private-subnets.yaml, while using https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json, I encountered one hard schema error.

In all-spec.json,

    "FnOr" : {
      "type" : "object",
      "properties" : {
        "description" : "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-conditions.html#intrinsic-function-reference-conditions-or",
        "Fn::Or" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Condition"
          },
          "minItems" : 2,
          "maxItems" : 10
        }
      },
      "additionalProperties" : false
    }

Is invalid, description might be in wrong place and should be a sibling of "type" : "array"? Schema refuse to load due to this bug. As of now it says description must be either object or boolean.

After working around this, this sea of validation errors were detected:

[{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property DependsOn is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 97,
    "startColumn": 5,
    "endLineNumber": 97,
    "endColumn": 14
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property DependsOn is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 105,
    "startColumn": 5,
    "endLineNumber": 105,
    "endColumn": 14
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property DependsOn is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 115,
    "startColumn": 5,
    "endLineNumber": 115,
    "endColumn": 14
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property DependsOn is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 125,
    "startColumn": 5,
    "endLineNumber": 125,
    "endColumn": 14
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property DependsOn is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 138,
    "startColumn": 5,
    "endLineNumber": 138,
    "endColumn": 14
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property DependsOn is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 151,
    "startColumn": 5,
    "endLineNumber": 151,
    "endColumn": 14
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property DependsOn is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 158,
    "startColumn": 5,
    "endLineNumber": 158,
    "endColumn": 14
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property Metadata is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 166,
    "startColumn": 5,
    "endLineNumber": 166,
    "endColumn": 13
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"array\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 173,
    "startColumn": 11,
    "endLineNumber": 175,
    "endColumn": 1
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected one of string, object.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 183,
    "startColumn": 16,
    "endLineNumber": 183,
    "endColumn": 17
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"string | FnBase64 | FnCidr | FnFindInMap | FnGetAtt | FnGetAZs | FnImportValue | FnJoin | object | FnSelect | FnSplit | FnSub\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 183,
    "startColumn": 16,
    "endLineNumber": 183,
    "endColumn": 17
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property Metadata is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 187,
    "startColumn": 5,
    "endLineNumber": 187,
    "endColumn": 13
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"array\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 194,
    "startColumn": 11,
    "endLineNumber": 196,
    "endColumn": 1
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected one of string, object.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 204,
    "startColumn": 16,
    "endLineNumber": 204,
    "endColumn": 17
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"string | FnBase64 | FnCidr | FnFindInMap | FnGetAtt | FnGetAZs | FnImportValue | FnJoin | object | FnSelect | FnSplit | FnSub\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 204,
    "startColumn": 16,
    "endLineNumber": 204,
    "endColumn": 17
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property Metadata is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 208,
    "startColumn": 5,
    "endLineNumber": 208,
    "endColumn": 13
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"array\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 214,
    "startColumn": 11,
    "endLineNumber": 216,
    "endColumn": 1
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected one of string, object.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 224,
    "startColumn": 16,
    "endLineNumber": 224,
    "endColumn": 17
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"string | FnBase64 | FnCidr | FnFindInMap | FnGetAtt | FnGetAZs | FnImportValue | FnJoin | object | FnSelect | FnSplit | FnSub\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 224,
    "startColumn": 16,
    "endLineNumber": 224,
    "endColumn": 17
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Property Metadata is not allowed.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 228,
    "startColumn": 5,
    "endLineNumber": 228,
    "endColumn": 13
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"array\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 234,
    "startColumn": 11,
    "endLineNumber": 236,
    "endColumn": 1
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected one of string, object.",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 244,
    "startColumn": 16,
    "endLineNumber": 244,
    "endColumn": 17
},{
    "resource": "/home/username/projects/ansible_aws_eks/playbooks/files/cloudformation/vpc_public_private_subnets-template.yaml",
    "owner": "_generated_diagnostic_collection_name_#1",
    "severity": 8,
    "message": "Incorrect type. Expected \"string | FnBase64 | FnCidr | FnFindInMap | FnGetAtt | FnGetAZs | FnImportValue | FnJoin | object | FnSelect | FnSplit | FnSub\".",
    "source": "yaml-schema: file:///home/username/projects/ansible_aws_eks/schemas/all-spec.json",
    "startLineNumber": 244,
    "startColumn": 16,
    "endLineNumber": 244,
    "endColumn": 17
}]

I'm assuming a cloudformation schema provided by Amazon should pass validation. That link is given in official AWS EKS documentation. It's possible that schema link is not recent, if there is a new link that will have an updated json spec, I'd really appreciate it.

PatMyron commented 7 months ago

See pinned issue https://github.com/aws-cloudformation/cloudformation-template-schema/issues/32