forked from aws-cloudformation/cfn-lint
-
Notifications
You must be signed in to change notification settings - Fork 2
/
UniqueNames.py
27 lines (23 loc) · 973 Bytes
/
UniqueNames.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
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""
from cfnlint.rules import CloudFormationLintRule, RuleMatch
from cfnlint.template import Template
class UniqueNames(CloudFormationLintRule):
id = "E3007"
shortdesc = "Unique resource and parameter names"
description = "All resources and parameters must have unique names"
source_url = "https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resources-section-structure.html"
tags = ["parameters", "resources"]
def match(self, cfn: Template):
matches = []
for resource in cfn.get_resources():
if resource in cfn.template.get("Parameters", {}):
matches.append(
RuleMatch(
["Resources", resource],
"Resources and Parameters must not share name: " + resource,
)
)
return matches