-
Notifications
You must be signed in to change notification settings - Fork 597
/
ImportValue.py
38 lines (32 loc) · 1.25 KB
/
ImportValue.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
31
32
33
34
35
36
37
38
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from collections import deque
from typing import Any, Iterator
from cfnlint.jsonschema import ValidationError, Validator
from cfnlint.rules import CloudFormationLintRule
class ImportValue(CloudFormationLintRule):
"""Check if a Output is done of another output"""
id = "W6001"
shortdesc = "Check Outputs using ImportValue"
description = (
"Check if the Output value is set using ImportValue, so creating an Output of"
" an Output"
)
source_url = "https://github.com/aws-cloudformation/cfn-lint"
tags = ["outputs", "importvalue"]
def validate(
self, validator: Validator, s: Any, instance: Any, schema: Any
) -> Iterator[ValidationError]:
if len(validator.context.path.path) >= 3:
if (
validator.context.path.path[0] == "Outputs"
and validator.context.path.path[2] == "Value"
):
key = list(instance.keys())[0]
yield ValidationError(
(f"The output value {instance!r} is an import from another output"),
rule=self,
path=deque([key]),
)