Skip to content

Commit 03747f9

Browse files
authored
Fix rule E2520 when empty lists are used (#2891)
1 parent 60714ec commit 03747f9

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

src/cfnlint/rules/resources/properties/Exclusive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def check(self, properties, exclusions, path, cfn):
4040
for prop in obj:
4141
if prop == k:
4242
for excl_property in exclusions[prop]:
43-
if excl_property in obj:
43+
if obj.get(excl_property):
4444
if property_set["Scenario"] is None:
4545
message = "Property {0} should NOT exist with {1} for {2}"
4646
matches.append(

test/fixtures/templates/good/resources/properties/exclusive.yaml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,47 @@ Resources:
55
SourceSecurityGroupId: sg-abc12345
66
CidrIp: !Ref AWS::NoValue
77
IpProtocol: "-1"
8-
GroupId: sg-abc1234567
8+
GroupId: sg-abc1234567
9+
Alarm:
10+
Type: AWS::CloudWatch::Alarm
11+
Properties:
12+
AlarmName: !Sub "${AWS::StackName}-ALB-5XX-Percentage"
13+
ActionsEnabled: true
14+
OKActions: []
15+
AlarmActions: []
16+
InsufficientDataActions: []
17+
Dimensions: []
18+
EvaluationPeriods: 15
19+
DatapointsToAlarm: 3
20+
Threshold: 5
21+
ComparisonOperator: GreaterThanOrEqualToThreshold
22+
TreatMissingData: notBreaching
23+
Metrics:
24+
- Id: e1
25+
Label: ALB 5XX Percentage
26+
ReturnData: true
27+
Expression: (m2/(m1+m2+m3+0.001))*100
28+
- Id: m1
29+
ReturnData: false
30+
MetricStat:
31+
Metric:
32+
Namespace: AWS/ApplicationELB
33+
MetricName: RequestCount
34+
Period: 60
35+
Stat: Sum
36+
- Id: m2
37+
ReturnData: false
38+
MetricStat:
39+
Metric:
40+
Namespace: AWS/ApplicationELB
41+
MetricName: HTTPCode_ELB_5XX_Count
42+
Period: 60
43+
Stat: Sum
44+
- Id: m3
45+
ReturnData: false
46+
MetricStat:
47+
Metric:
48+
Namespace: AWS/ApplicationELB
49+
MetricName: HTTPCode_ELB_4XX_Count
50+
Period: 60
51+
Stat: Sum

test/unit/rules/resources/properties/test_exclusive.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ def setUp(self):
1616
"""Setup"""
1717
super(TestPropertyExclusive, self).setUp()
1818
self.collection.register(Exclusive())
19+
self.success_templates = [
20+
"test/fixtures/templates/good/resources/properties/exclusive.yaml"
21+
]
1922

2023
def test_file_positive(self):
2124
"""Test Positive"""

0 commit comments

Comments
 (0)