Skip to content

Commit

Permalink
Fix NetworkFirewall properties
Browse files Browse the repository at this point in the history
- Added Property type for FirewallPolicy
- Added Property type for RuleGroup
- Added validation for RuleGroup.Type
- Fix for linting
- Fixes #1933
  • Loading branch information
avosper-intellaegis authored Jul 24, 2021
1 parent 49b6b54 commit 53e8e69
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions troposphere/networkfirewall.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@
from .validators import boolean, integer


VALID_RULE_GROUP_TYPES = (
"STATEFUL",
"STATELESS"
)


def validate_rule_group_type(rule_group_type):
"""Validate Type for RuleGroup"""
if rule_group_type not in VALID_RULE_GROUP_TYPES:
raise ValueError(
"RuleGroup Type must be one of %s"
% ", ".join(VALID_RULE_GROUP_TYPES)
)
return rule_group_type


class SubnetMapping(AWSProperty):
props = {
"SubnetId": (str, True),
Expand Down Expand Up @@ -73,7 +89,7 @@ class StatelessRuleGroupReference(AWSProperty):
}


class FirewallPolicy(AWSProperty):
class FirewallPolicyProperty(AWSProperty):
props = {
"StatefulRuleGroupReferences": ([StatefulRuleGroupReference], False),
"StatelessCustomActions": ([CustomAction], False),
Expand All @@ -83,6 +99,17 @@ class FirewallPolicy(AWSProperty):
}


class FirewallPolicy(AWSObject):
resource_type = "AWS::NetworkFirewall::FirewallPolicy"

props = {
"Description": (str, False),
"FirewallPolicyName": (str, True),
"Tags": (Tags, False),
"FirewallPolicy": (FirewallPolicyProperty, True),
}


class LogDestinationConfig(AWSProperty):
props = {
"LogDestination": (dict, True),
Expand Down Expand Up @@ -199,8 +226,21 @@ class RulesSource(AWSProperty):
}


class RuleGroup(AWSProperty):
class RuleGroupProperty(AWSProperty):
props = {
"RuleVariables": (RuleVariables, False),
"RulesSource": (RulesSource, True),
}


class RuleGroup(AWSObject):
resource_type = "AWS::NetworkFirewall::RuleGroup"

props = {
"Capacity": (integer, True),
"Description": (str, False),
"RuleGroup": (RuleGroupProperty, False),
"RuleGroupName": (str, True),
"Tags": (Tags, False),
"Type": (validate_rule_group_type, True)
}

0 comments on commit 53e8e69

Please sign in to comment.