Skip to content

Commit 8cc931a

Browse files
authored
Update E3044 to handle conditions (#2600)
1 parent edc55f4 commit 8cc931a

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/cfnlint/rules/resources/ecs/FargateDeploymentSchedulingStrategy.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ def match(self, cfn):
2020
path = ecs_service["Path"]
2121
properties = ecs_service["Value"]
2222
if isinstance(properties, dict):
23-
launch_type = properties.get("LaunchType", None)
24-
if isinstance(launch_type, str) and launch_type == "Fargate":
25-
scheduling_strategy = properties.get("SchedulingStrategy", None)
26-
if (
27-
isinstance(scheduling_strategy, str)
28-
and scheduling_strategy != "REPLICA"
29-
):
30-
error_message = f"Fargate service only support REPLICA as scheduling strategy at {'/'.join(map(str, path))}"
31-
matches.append(RuleMatch(path, error_message))
23+
scenarios = cfn.get_object_without_conditions(
24+
properties, ["LaunchType", "SchedulingStrategy"]
25+
)
26+
for scenario in scenarios:
27+
props = scenario.get("Object")
28+
launch_type = props.get("LaunchType", None)
29+
if isinstance(launch_type, str) and launch_type == "FARGATE":
30+
scheduling_strategy = props.get("SchedulingStrategy", None)
31+
if (
32+
isinstance(scheduling_strategy, str)
33+
and scheduling_strategy != "REPLICA"
34+
):
35+
error_message = f"Fargate service only support REPLICA as scheduling strategy at {'/'.join(map(str, path))}"
36+
matches.append(RuleMatch(path, error_message))
3237
return matches

test/fixtures/templates/bad/resources/ecs/test_fargate_scheduling_strategy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ Resources:
22
Service1:
33
Type: AWS::ECS::Service
44
Properties:
5-
LaunchType: Fargate
5+
LaunchType: FARGATE
66
SchedulingStrategy: DAEMON

0 commit comments

Comments
 (0)