JSON Schema false warnings for CloudFormation templates

Answered

When I use verbose version of some functions such as Fn::Select, IDEA is giving me a false warning:

I noticed IDEA is using this schema definition: https://raw.githubusercontent.com/awslabs/goformation/v5.2.11/schema/cloudformation.schema.json

Just FYI, this is an old version of the schema definition and the last one available in this GitHub repo is: https://github.com/awslabs/goformation/blob/v5.4.5/schema/cloudformation.schema.json

Unfortunately even this version is declaring the type as `string`:

        "AWS::EC2::Subnet": {
            "additionalProperties": false,
            "properties": {
                "DeletionPolicy": {
                    "enum": [
                        "Delete",
                        "Retain",
                        "Snapshot"
                    ],
                    "type": "string"
                },
                "DependsOn": {
                    "anyOf": [
                        {
                            "pattern": "^[a-zA-Z0-9]+$",
                            "type": "string"
                        },
                        {
                            "items": {
                                "pattern": "^[a-zA-Z0-9]+$",
                                "type": "string"
                            },
                            "type": "array"
                        }
                    ]
                },
                "Metadata": {
                    "type": "object"
                },
                "Properties": {
                    "additionalProperties": false,
                    "properties": {
                        "AssignIpv6AddressOnCreation": {
                            "type": "boolean"
                        },
                        "AvailabilityZone": {
                            "type": "string"
                      },

Also, I think there's a more accurate JSON schema is available for CloudFormation at: https://s3.amazonaws.com/cfn-resource-specifications-us-east-1-prod/schemas/2.15.0/all-spec.json

Here, the type is defined to be Expression:

  "AWS_EC2_Subnet" : {
    "type" : "object",
    "description" : "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html",
    "properties" : {
      "Type" : {
        "description" : "Type of resource equals only AWS::EC2::Subnet",
        "type" : "string",
        "enum" : [ "AWS::EC2::Subnet" ]
      },
      "Properties" : {
        "type" : "object",
        "properties" : {
          "AssignIpv6AddressOnCreation" : {
            "description" : "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#cfn-ec2-subnet-assignipv6addressoncreation",
            "anyOf" : [ {
              "type" : "boolean"
            }, {
              "$ref" : "#/definitions/Expression"
            } ]
          },
          "AvailabilityZone" : {
            "description" : "http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-ec2-subnet.html#cfn-ec2-subnet-availabilityzone",
            "$ref" : "#/definitions/Expression"
        },

However, even if I use this JSON Schema, I still get false validation warnings, this time even if I use the concise function notations using exclamation mark (e.g. !FindInMap)

Are there any other schemas that don't produce these false warnings?

1

Please sign in to leave a comment.