Skip to content

Commit

Permalink
Fix Fargate strategy rule to handle non string properties
Browse files Browse the repository at this point in the history
Change:

Intrinsic functions can be used for resource properties and previously
this rule checker doesn't handle such scenario.
  • Loading branch information
lejiati committed Feb 21, 2023
1 parent d5c3dfe commit 376758d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ def match(self, cfn):
path = ecs_service["Path"]
properties = ecs_service["Value"]
if isinstance(properties, dict):
if properties.get("LaunchType", None) != "Fargate":
continue
if properties.get("SchedulingStrategy", None) != "REPLICA":
error_message = f"Fargate service only support REPLICA as scheduling strategy at {'/'.join(map(str, path))}"
matches.append(RuleMatch(path, error_message))
launch_type = properties.get("LaunchType", None)
if isinstance(launch_type, str) and \
launch_type == "Fargate":
scheduling_strategy = properties.get("SchedulingStrategy", None)
if isinstance(scheduling_strategy, str) and \
scheduling_strategy != "REPLICA":
error_message = f"Fargate service only support REPLICA as scheduling strategy at {'/'.join(map(str, path))}"
matches.append(RuleMatch(path, error_message))
return matches
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ Resources:
Properties:
LaunchType: EXTERNAL
SchedulingStrategy: DAEMON
Service4:
Type: AWS::ECS::Service
Properties:
LaunchType: !Join ["", ["FAR", "GATE"]]
SchedulingStrategy: DAEMON

0 comments on commit 376758d

Please sign in to comment.