{
    "$schema": "http://json-schema.org/schema#",
    "type": "object",
    "properties": {
        "type": {
            "type": "string",
            "description": "The service type (should always be 'dynamodb')",
            "pattern": "^dynamodb$",
            "errorMesssage": "Must be 'dynamodb'"
        },
        "table_name": {
            "type": "string",
            "minLength": 3,
            "maxLength": 255,
            "pattern": "^[a-zA-Z0-9_\\-.]*$",
            "errorMessage": "Must be between 3 and 255 characters long and may only include alphanumeric characters, underscores (_), hyphens (-), and dots (.)"
        },
        "partition_key": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "errorMessage": "Must be a string"
                },
                "type": {
                    "type": "string",
                    "description": "The 'type' parameter may only be 'String' or 'Number'",
                    "pattern": "^String|string|Number|number$",
                    "errorMessage": "Must be 'String', 'string', 'Number' or 'number'"
                }
            },
            "required": [
                "name",
                "type"
            ],
            "additionalProperties": false,
            "errorMessage": {
                "required": {
                    "name": "The 'name' field is required",
                    "type": "The 'type' field is required"
                },
                "additionalProperties": "Invalid/Unknown property specified"
            }
        },
        "sort_key": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "errorMessage": "Must be a string"
                },
                "type": {
                    "type": "string",
                    "description": "The 'type' parameter may only be 'String' or 'Number'",
                    "pattern": "^String|string|Number|number$",
                    "errorMessage": "Must be 'String', 'string', 'Number' or 'number'"
                }
            },
            "required": [
                "name",
                "type"
            ],
            "additionalProperties": false,
            "errorMessage": {
                "required": {
                    "name": "The 'name' field is required",
                    "type": "The 'type' field is required"
                },
                "additionalProperties": "Invalid/Unknown property specified"
            }
        },
        "provisioned_throughput": {
            "type": "object",
            "properties": {
                "read_capacity_units": {
                    "oneOf": [
                        {
                            "type": "string",
                            "pattern": "^(\\d+)(?:-(\\d+))?$"
                        },
                        {
                            "type": "integer"
                        }
                    ],
                    "errorMessage": "Must be either a number or a numeric range (ex: 1-100)"
                },
                "write_capacity_units": {
                    "oneOf": [
                        {
                            "type": "string",
                            "pattern": "^(\\d+)(?:-(\\d+))?$"
                        },
                        {
                            "type": "integer"
                        }
                    ],
                    "errorMessage": "Must be either a number or a numeric range (ex: 1-100)"
                },
                "read_target_utilization": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100,
                    "errorMessage": "Must be a percentage"
                },
                "write_target_utilization": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 100,
                    "errorMessage": "Must be a percentage"
                }
            },
            "required": [
                "read_capacity_units",
                "write_capacity_units"
            ],
            "additionalProperties": false,
            "errorMessage": {
                "required": {
                    "read_capacity_units": "The 'read_capacity_units' are required",
                    "write_capacity_units": "The 'write_capacity_units' are required"
                },
                "additionalProperties": "Invalid/Unknown property specified"
            }
        },
        "ttl_attribute": {
            "type": "string",
            "errorMessage": "Must be a string"
        },
        "local_indexes": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": "string",
                        "errorMessage": "Must be a string"
                    },
                    "sort_key": {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string",
                                "errorMessage": "Must be a string"
                            },
                            "type": {
                                "type": "string",
                                "description": "The 'type' parameter may only be 'String' or 'Number'",
                                "pattern": "^String|string|Number|number$",
                                "errorMessage": "Must be 'String', 'string', 'Number' or 'number'"
                            }
                        },
                        "additionalProperties": false,
                        "required": [
                            "name",
                            "type"
                        ],
                        "errorMessage": {
                            "required": {
                                "name": "The 'name' field is required",
                                "type": "The 'type' field is required"
                            },
                            "additionalProperties": "Invalid/Unknown property specified"
                        }
                    },
                    "attributes_to_copy": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "errorMessage": "Items must be strings"
                        },
                        "errorMessage": "Must be an array"
                    }
                },
                "required": [
                    "name",
                    "sort_key",
                    "attributes_to_copy"
                ],
                "additionalProperties": false,
                "errorMessage": {
                    "required": {
                        "name": "The 'name' field is required",
                        "sort_key": "The 'sort_key' section is required",
                        "attributes_to_copy": "The 'attributes_to_copy' field is required"
                    },
                    "additionalProperties": "Invalid/Unknown property specified"
                }
            }
        },
        "stream_view_type": {
            "type": "string",
            "description": "The 'stream_view_type' parameter only accepts 'KEYS_ONLY', 'NEW_IMAGE', 'OLD_IMAGE', and 'NEW_AND_OLD_IMAGES'",
            "pattern": "^KEYS_ONLY|NEW_IMAGE|OLD_IMAGE|NEW_AND_OLD_IMAGES$",
            "errorMessage": "Must be 'KEYS_ONLY', 'NEW_IMAGE', 'OLD_IMAGE', or 'NEW_AND_OLD_IMAGES'"
        },
        "global_indexes": {
            "type": "array",
            "items": {
                "properties": {
                    "name": {
                        "type": "string",
                        "errorMessage": "Must be a string"
                    },
                    "partition_key": {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string",
                                "errorMessage": "Must be a string"
                            },
                            "type": {
                                "type": "string",
                                "description": "The 'type' parameter may only be 'String' or 'Number'",
                                "pattern": "^String|string|Number|number$",
                                "errorMessage": "Must be 'String', 'string', 'Number' or 'number'"
                            }
                        },
                        "required": [
                            "name",
                            "type"
                        ],
                        "additionalProperties": false,
                        "errorMessage": {
                            "required": {
                                "name": "The 'name' field is required",
                                "type": "The 'type' field is required"
                            },
                            "additionalProperties": "Invalid/Unknown property specified"
                        }
                    },
                    "sort_key": {
                        "type": "object",
                        "properties": {
                            "name": {
                                "type": "string",
                                "errorMessage": "Must be a string in the 'sort_key' section"
                            },
                            "type": {
                                "type": "string",
                                "description": "The 'type' parameter may only be 'String' or 'Number' in the 'sort_key' section",
                                "pattern": "^String|string|Number|number$",
                                "errorMessage": "Must be 'String', 'string', 'Number' or 'number'"
                            }
                        },
                        "required": [
                            "name",
                            "type"
                        ],
                        "additionalProperties": false,
                        "errorMessage": {
                            "required": {
                                "name": "The 'name' field is required",
                                "type": "The 'type' field is required"
                            },
                            "additionalProperties": "Invalid/Unknown property specified"
                        }
                    },
                    "attributes_to_copy": {
                        "type": "array",
                        "items": {
                            "type": "string",
                            "errorMessage": "Items must be strings"
                        },
                        "errorMessage": "Must be an array of strings"
                    },
                    "provisioned_throughput": {
                        "type": "object",
                        "properties": {
                            "read_capacity_units": {
                                "oneOf": [
                                    {
                                        "type": "string",
                                        "pattern": "^(\\d+)(?:-(\\d+))?$"
                                    },
                                    {
                                        "type": "integer"
                                    }
                                ],
                                "errorMessage": "Must be either a number or a numeric range (ex: 1-100)"
                            },
                            "write_capacity_units": {
                                "oneOf": [
                                    {
                                        "type": "string",
                                        "pattern": "^(\\d+)(?:-(\\d+))?$"
                                    },
                                    {
                                        "type": "integer"
                                    }
                                ],
                                "errorMessage": "Must be either a number or a numeric range (ex: 1-100)"
                            },
                            "read_target_utilization": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100,
                                "errorMessage": "Must be a number between 0 and 100"
                            },
                            "write_target_utilization": {
                                "type": "number",
                                "minimum": 0,
                                "maximum": 100,
                                "errorMessage": "Must be a number between 0 and 100"
                            }
                        },
                        "additionalProperties": false,
                        "errorMessage": {
                            "required": {
                                "read_capacity_units": "The 'read_capacity_units' are required",
                                "write_capacity_units": "The 'write_capacity_units' are required"
                            },
                            "additionalProperties": "Invalid/Unknown property specified"
                        }
                    }
                },
                "required": [
                    "name",
                    "partition_key"
                ],
                "additionalProperties": false,
                "errorMessage": {
                    "required": {
                        "name": "The 'name' field is required",
                        "partition_key": "The 'partition_key' section is required"
                    },
                    "additionalProperties": "Invalid/Unknown property specified"
                }
            }
        },
        "event_consumers": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "service_name": {
                        "type": "string",
                        "description": "The service name of the lambda function",
                        "errorMessage": "The 'service_name' parameter is required in each config"
                    },
                    "batch_size": {
                        "type": "number",
                        "errorMessage": "Must be a number"
                    }
                },
                "required": [
                    "service_name"
                ],
                "additionalProperties": false,
                "errorMessage": {
                    "required": {
                        "service_name": "The 'service_name' parameter is required"
                    },
                    "additionalProperties": "Invalid/Unknown property specified"
                }
                
            }
        },
        "tags": {
            "type": "object",
            "description": "An arbitrary list of key/value pairs to be added as tags to the service",
            "patternProperties": {
                "^.*$": {
                    "anyOf": [
                        {"type": "string"},
                        {"type": "number"}
                    ]
                }
            },
            "errorMessage": "Must contain 1 or more simple key/value pairs where the values are strings or numbers",
            "additionalProperties": false
        }
    },
    "required": [
        "type",
        "partition_key"
    ],
    "additionalProperties": false,
    "errorMessage": {
        "required": {
            "type": "The 'type' parameter is required",
            "partition_key": "The 'partition_key' section is required"
        },
        "additionalProperties": "Invalid/Unknown property specified"
    }
}