Skip to content

Commit ad6ddb6

Browse files
authored
Add exceptions to I3037 (#2927)
1 parent 72de429 commit ad6ddb6

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

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

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ class ListDuplicatesAllowed(CloudFormationLintRule):
2121
source_url = "https://github.com/aws-cloudformation/cfn-python-lint/blob/main/docs/rules.md#rules-1"
2222
tags = ["resources", "property", "list"]
2323

24+
def __init__(self):
25+
super().__init__()
26+
self.exceptions = ["Command"]
27+
2428
def initialize(self, cfn):
2529
"""Initialize the rule"""
2630
for resource_type_spec in RESOURCE_SPECS.get(cfn.regions[0]).get(
@@ -71,11 +75,15 @@ def check_duplicates(self, values, path, cfn):
7175
"""Check for duplicates"""
7276
matches = []
7377

78+
if path[-1] in self.exceptions:
79+
return matches
7480
if isinstance(values, list):
7581
matches.extend(self._check_duplicates(values, path))
7682
elif isinstance(values, dict):
7783
props = cfn.get_object_without_conditions(values)
7884
for prop in props:
85+
if prop in self.exceptions:
86+
continue
7987
matches.extend(
8088
self._check_duplicates(
8189
prop.get("Object"), path, prop.get("Scenario")

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

+20-8
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Metadata:
44
cfn-lint:
55
config:
66
include_checks:
7-
- I
7+
- I
88
Parameters:
99
PrimaryRegion:
1010
Type: String
@@ -13,7 +13,7 @@ Parameters:
1313
PrivateSubnetTwo:
1414
Type: String
1515
Conditions:
16-
isPrimaryRegion: !Equals [!Ref PrimaryRegion, 'us-east-1']
16+
isPrimaryRegion: !Equals [!Ref PrimaryRegion, "us-east-1"]
1717
Resources:
1818
MyASG:
1919
Type: AWS::AutoScaling::AutoScalingGroup
@@ -32,17 +32,29 @@ Resources:
3232
MinSize: "1"
3333
VPCZoneIdentifier:
3434
Fn::If:
35-
- isPrimaryRegion
36-
- - !Ref PrivateSubnetOne
37-
- !Ref PrivateSubnetTwo
38-
- - !Ref PrivateSubnetOne
39-
- !Ref PrivateSubnetTwo
35+
- isPrimaryRegion
36+
- - !Ref PrivateSubnetOne
37+
- !Ref PrivateSubnetTwo
38+
- - !Ref PrivateSubnetOne
39+
- !Ref PrivateSubnetTwo
4040
MyASG3:
4141
Type: AWS::AutoScaling::AutoScalingGroup
4242
Properties:
4343
InstanceId: abc-123456
4444
MaxSize: "1"
4545
MinSize: "1"
4646
VPCZoneIdentifier:
47-
- !If ['isPrimaryRegion', !Ref PrivateSubnetTwo, !Ref PrivateSubnetOne]
47+
- !If ["isPrimaryRegion", !Ref PrivateSubnetTwo, !Ref PrivateSubnetOne]
4848
- "subnet-123456"
49+
MyECSTaskDefinition:
50+
Type: AWS::ECS::TaskDefinition
51+
Properties:
52+
ContainerDefinitions:
53+
- Command:
54+
- do_something
55+
- --foo
56+
- "1"
57+
- --bar
58+
- "1"
59+
Image: my-image
60+
Name: my-task

0 commit comments

Comments
 (0)