forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Exists.py
30 lines (24 loc) · 991 Bytes
/
Exists.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from typing import Any
from cfnlint.jsonschema import Validator
from cfnlint.rules import CloudFormationLintRule
class Exists(CloudFormationLintRule):
"""Check if used Conditions are defined"""
id = "E8002"
shortdesc = "Check if the referenced Conditions are defined"
description = (
"Making sure the used conditions are actually defined in the Conditions section"
)
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/conditions-section-structure.html"
tags = ["conditions"]
def cfncondition(self, validator: Validator, conditions, instance: Any, schema):
if not validator.is_type(instance, "string"):
return
for err in validator.descend(
instance, {"enum": list(validator.context.conditions.conditions.keys())}
):
err.rule = self
yield err