in cfn_policy_validator/cfn_tools/schema_validator.py [0:0]
def validate(template):
# this schema validates that the CloudFormation template has a valid Resources, Parameters, and Mappings section.
# validating upfront allows us to make assumptions later that we're dealing with a valid template
template_schema = {
'type': 'object',
'properties': {
'Resources': {
'type': 'object',
'patternProperties': {
alphanumeric_regex: {
'type': 'object',
'properties': {
'Type': {
'type': 'string'
},
'Properties': {
'type': 'object'
}
},
'required': ['Type']
}
},
'additionalProperties': False
},
'Parameters': {
'type': 'object',
'additionalProperties': {
'type': 'object'
}
},
'Mappings': {
'type': 'object',
'patternProperties': {
alphanumeric_regex: {
'type': 'object',
'patternProperties': {
'^.*$': {
'type': 'object',
'patternProperties': {
'^.*$': {
'type': ['string', 'array'],
'minProperties': 1
}
},
'minProperties': 1,
'additionalProperties': False
}
},
'minProperties': 1,
'additionalProperties': False
}
},
'additionalProperties': False
}
},
'required': ['Resources']
}
validate_schema(template, template_schema)