Skip to content
v2.277.0

RuleGroupProperty Struct ​

The object that defines the rules in a rule group.

AWS Network Firewall uses a rule group to inspect and control network traffic. You define stateless rule groups to inspect individual packets and you define stateful rule groups to inspect packets in the context of their traffic flow.

To use a rule group, you include it by reference in an Network Firewall firewall policy, then you use the policy in a firewall. You can reference a rule group from more than one firewall policy, and you can use a firewall policy in more than one firewall.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_networkfirewall as networkfirewall } from 'aws-cdk-lib';
const ruleGroupProperty: networkfirewall.CfnRuleGroup.RuleGroupProperty = {
  rulesSource: {
    rulesSourceList: {
      generatedRulesType: 'generatedRulesType',
      targets: ['targets'],
      targetTypes: ['targetTypes'],
    },
    rulesString: 'rulesString',
    statefulRules: [{
      action: 'action',
      header: {
        destination: 'destination',
        destinationPort: 'destinationPort',
        direction: 'direction',
        protocol: 'protocol',
        source: 'source',
        sourcePort: 'sourcePort',
      },
      ruleOptions: [{
        keyword: 'keyword',

        // the properties below are optional
        settings: ['settings'],
      }],
    }],
    statelessRulesAndCustomActions: {
      statelessRules: [{
        priority: 123,
        ruleDefinition: {
          actions: ['actions'],
          matchAttributes: {
            destinationPorts: [{
              fromPort: 123,
              toPort: 123,
            }],
            destinations: [{
              addressDefinition: 'addressDefinition',
            }],
            protocols: [123],
            sourcePorts: [{
              fromPort: 123,
              toPort: 123,
            }],
            sources: [{
              addressDefinition: 'addressDefinition',
            }],
            tcpFlags: [{
              flags: ['flags'],

              // the properties below are optional
              masks: ['masks'],
            }],
          },
        },
      }],

      // the properties below are optional
      customActions: [{
        actionDefinition: {
          publishMetricAction: {
            dimensions: [{
              value: 'value',
            }],
          },
        },
        actionName: 'actionName',
      }],
    },
  },

  // the properties below are optional
  referenceSets: {
    ipSetReferences: {
      ipSetReferencesKey: {
        referenceArn: 'referenceArn',
      },
    },
  },
  ruleVariables: {
    ipSets: {
      ipSetsKey: {
        definition: ['definition'],
      },
    },
    portSets: {
      portSetsKey: {
        definition: ['definition'],
      },
    },
  },
  statefulRuleOptions: {
    ruleOrder: 'ruleOrder',
  },
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_networkfirewall as networkfirewall

rule_group_property = networkfirewall.CfnRuleGroup.RuleGroupProperty(
    rules_source=networkfirewall.CfnRuleGroup.RulesSourceProperty(
        rules_source_list=networkfirewall.CfnRuleGroup.RulesSourceListProperty(
            generated_rules_type="generatedRulesType",
            targets=["targets"],
            target_types=["targetTypes"]
        ),
        rules_string="rulesString",
        stateful_rules=[networkfirewall.CfnRuleGroup.StatefulRuleProperty(
            action="action",
            header=networkfirewall.CfnRuleGroup.HeaderProperty(
                destination="destination",
                destination_port="destinationPort",
                direction="direction",
                protocol="protocol",
                source="source",
                source_port="sourcePort"
            ),
            rule_options=[networkfirewall.CfnRuleGroup.RuleOptionProperty(
                keyword="keyword",

                # the properties below are optional
                settings=["settings"]
            )]
        )],
        stateless_rules_and_custom_actions=networkfirewall.CfnRuleGroup.StatelessRulesAndCustomActionsProperty(
            stateless_rules=[networkfirewall.CfnRuleGroup.StatelessRuleProperty(
                priority=123,
                rule_definition=networkfirewall.CfnRuleGroup.RuleDefinitionProperty(
                    actions=["actions"],
                    match_attributes=networkfirewall.CfnRuleGroup.MatchAttributesProperty(
                        destination_ports=[networkfirewall.CfnRuleGroup.PortRangeProperty(
                            from_port=123,
                            to_port=123
                        )],
                        destinations=[networkfirewall.CfnRuleGroup.AddressProperty(
                            address_definition="addressDefinition"
                        )],
                        protocols=[123],
                        source_ports=[networkfirewall.CfnRuleGroup.PortRangeProperty(
                            from_port=123,
                            to_port=123
                        )],
                        sources=[networkfirewall.CfnRuleGroup.AddressProperty(
                            address_definition="addressDefinition"
                        )],
                        tcp_flags=[networkfirewall.CfnRuleGroup.TCPFlagFieldProperty(
                            flags=["flags"],

                            # the properties below are optional
                            masks=["masks"]
                        )]
                    )
                )
            )],

            # the properties below are optional
            custom_actions=[networkfirewall.CfnRuleGroup.CustomActionProperty(
                action_definition=networkfirewall.CfnRuleGroup.ActionDefinitionProperty(
                    publish_metric_action=networkfirewall.CfnRuleGroup.PublishMetricActionProperty(
                        dimensions=[networkfirewall.CfnRuleGroup.DimensionProperty(
                            value="value"
                        )]
                    )
                ),
                action_name="actionName"
            )]
        )
    ),

    # the properties below are optional
    reference_sets=networkfirewall.CfnRuleGroup.ReferenceSetsProperty(
        ip_set_references={
            "ip_set_references_key": {
                "reference_arn": "referenceArn"
            }
        }
    ),
    rule_variables=networkfirewall.CfnRuleGroup.RuleVariablesProperty(
        ip_sets={
            "ip_sets_key": {
                "definition": ["definition"]
            }
        },
        port_sets={
            "port_sets_key": networkfirewall.CfnRuleGroup.PortSetProperty(
                definition=["definition"]
            )
        }
    ),
    stateful_rule_options=networkfirewall.CfnRuleGroup.StatefulRuleOptionsProperty(
        rule_order="ruleOrder"
    )
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.networkfirewall.*;

RuleGroupProperty ruleGroupProperty = RuleGroupProperty.builder()
        .rulesSource(RulesSourceProperty.builder()
                .rulesSourceList(RulesSourceListProperty.builder()
                        .generatedRulesType("generatedRulesType")
                        .targets(List.of("targets"))
                        .targetTypes(List.of("targetTypes"))
                        .build())
                .rulesString("rulesString")
                .statefulRules(List.of(StatefulRuleProperty.builder()
                        .action("action")
                        .header(HeaderProperty.builder()
                                .destination("destination")
                                .destinationPort("destinationPort")
                                .direction("direction")
                                .protocol("protocol")
                                .source("source")
                                .sourcePort("sourcePort")
                                .build())
                        .ruleOptions(List.of(RuleOptionProperty.builder()
                                .keyword("keyword")

                                // the properties below are optional
                                .settings(List.of("settings"))
                                .build()))
                        .build()))
                .statelessRulesAndCustomActions(StatelessRulesAndCustomActionsProperty.builder()
                        .statelessRules(List.of(StatelessRuleProperty.builder()
                                .priority(123)
                                .ruleDefinition(RuleDefinitionProperty.builder()
                                        .actions(List.of("actions"))
                                        .matchAttributes(MatchAttributesProperty.builder()
                                                .destinationPorts(List.of(PortRangeProperty.builder()
                                                        .fromPort(123)
                                                        .toPort(123)
                                                        .build()))
                                                .destinations(List.of(AddressProperty.builder()
                                                        .addressDefinition("addressDefinition")
                                                        .build()))
                                                .protocols(List.of(123))
                                                .sourcePorts(List.of(PortRangeProperty.builder()
                                                        .fromPort(123)
                                                        .toPort(123)
                                                        .build()))
                                                .sources(List.of(AddressProperty.builder()
                                                        .addressDefinition("addressDefinition")
                                                        .build()))
                                                .tcpFlags(List.of(TCPFlagFieldProperty.builder()
                                                        .flags(List.of("flags"))

                                                        // the properties below are optional
                                                        .masks(List.of("masks"))
                                                        .build()))
                                                .build())
                                        .build())
                                .build()))

                        // the properties below are optional
                        .customActions(List.of(CustomActionProperty.builder()
                                .actionDefinition(ActionDefinitionProperty.builder()
                                        .publishMetricAction(PublishMetricActionProperty.builder()
                                                .dimensions(List.of(DimensionProperty.builder()
                                                        .value("value")
                                                        .build()))
                                                .build())
                                        .build())
                                .actionName("actionName")
                                .build()))
                        .build())
                .build())

        // the properties below are optional
        .referenceSets(ReferenceSetsProperty.builder()
                .ipSetReferences(Map.of(
                        "ipSetReferencesKey", Map.of(
                                "referenceArn", "referenceArn")))
                .build())
        .ruleVariables(RuleVariablesProperty.builder()
                .ipSets(Map.of(
                        "ipSetsKey", Map.of(
                                "definition", List.of("definition"))))
                .portSets(Map.of(
                        "portSetsKey", PortSetProperty.builder()
                                .definition(List.of("definition"))
                                .build()))
                .build())
        .statefulRuleOptions(StatefulRuleOptionsProperty.builder()
                .ruleOrder("ruleOrder")
                .build())
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.NetworkFirewall;

var ruleGroupProperty = new RuleGroupProperty {
    RulesSource = new RulesSourceProperty {
        RulesSourceList = new RulesSourceListProperty {
            GeneratedRulesType = "generatedRulesType",
            Targets = new [] { "targets" },
            TargetTypes = new [] { "targetTypes" }
        },
        RulesString = "rulesString",
        StatefulRules = new [] { new StatefulRuleProperty {
            Action = "action",
            Header = new HeaderProperty {
                Destination = "destination",
                DestinationPort = "destinationPort",
                Direction = "direction",
                Protocol = "protocol",
                Source = "source",
                SourcePort = "sourcePort"
            },
            RuleOptions = new [] { new RuleOptionProperty {
                Keyword = "keyword",

                // the properties below are optional
                Settings = new [] { "settings" }
            } }
        } },
        StatelessRulesAndCustomActions = new StatelessRulesAndCustomActionsProperty {
            StatelessRules = new [] { new StatelessRuleProperty {
                Priority = 123,
                RuleDefinition = new RuleDefinitionProperty {
                    Actions = new [] { "actions" },
                    MatchAttributes = new MatchAttributesProperty {
                        DestinationPorts = new [] { new PortRangeProperty {
                            FromPort = 123,
                            ToPort = 123
                        } },
                        Destinations = new [] { new AddressProperty {
                            AddressDefinition = "addressDefinition"
                        } },
                        Protocols = new [] { 123 },
                        SourcePorts = new [] { new PortRangeProperty {
                            FromPort = 123,
                            ToPort = 123
                        } },
                        Sources = new [] { new AddressProperty {
                            AddressDefinition = "addressDefinition"
                        } },
                        TcpFlags = new [] { new TCPFlagFieldProperty {
                            Flags = new [] { "flags" },

                            // the properties below are optional
                            Masks = new [] { "masks" }
                        } }
                    }
                }
            } },

            // the properties below are optional
            CustomActions = new [] { new CustomActionProperty {
                ActionDefinition = new ActionDefinitionProperty {
                    PublishMetricAction = new PublishMetricActionProperty {
                        Dimensions = new [] { new DimensionProperty {
                            Value = "value"
                        } }
                    }
                },
                ActionName = "actionName"
            } }
        }
    },

    // the properties below are optional
    ReferenceSets = new ReferenceSetsProperty {
        IpSetReferences = new Dictionary<string, object> {
            { "ipSetReferencesKey", new Dictionary<string, string?> {
                { "referenceArn", "referenceArn" }
            } }
        }
    },
    RuleVariables = new RuleVariablesProperty {
        IpSets = new Dictionary<string, object> {
            { "ipSetsKey", new Dictionary<string, string[]?> {
                { "definition", new [] { "definition" } }
            } }
        },
        PortSets = new Dictionary<string, object> {
            { "portSetsKey", new PortSetProperty {
                Definition = new [] { "definition" }
            } }
        }
    },
    StatefulRuleOptions = new StatefulRuleOptionsProperty {
        RuleOrder = "ruleOrder"
    }
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

ruleGroupProperty := &RuleGroupProperty{
	RulesSource: &RulesSourceProperty{
		RulesSourceList: &RulesSourceListProperty{
			GeneratedRulesType: jsii.String("generatedRulesType"),
			Targets: []*string{
				jsii.String("targets"),
			},
			TargetTypes: []*string{
				jsii.String("targetTypes"),
			},
		},
		RulesString: jsii.String("rulesString"),
		StatefulRules: []interface{}{
			&StatefulRuleProperty{
				Action: jsii.String("action"),
				Header: &HeaderProperty{
					Destination: jsii.String("destination"),
					DestinationPort: jsii.String("destinationPort"),
					Direction: jsii.String("direction"),
					Protocol: jsii.String("protocol"),
					Source: jsii.String("source"),
					SourcePort: jsii.String("sourcePort"),
				},
				RuleOptions: []interface{}{
					&RuleOptionProperty{
						Keyword: jsii.String("keyword"),

						// the properties below are optional
						Settings: []*string{
							jsii.String("settings"),
						},
					},
				},
			},
		},
		StatelessRulesAndCustomActions: &StatelessRulesAndCustomActionsProperty{
			StatelessRules: []interface{}{
				&StatelessRuleProperty{
					Priority: jsii.Number(123),
					RuleDefinition: &RuleDefinitionProperty{
						Actions: []*string{
							jsii.String("actions"),
						},
						MatchAttributes: &MatchAttributesProperty{
							DestinationPorts: []interface{}{
								&PortRangeProperty{
									FromPort: jsii.Number(123),
									ToPort: jsii.Number(123),
								},
							},
							Destinations: []interface{}{
								&AddressProperty{
									AddressDefinition: jsii.String("addressDefinition"),
								},
							},
							Protocols: []interface{}{
								jsii.Number(123),
							},
							SourcePorts: []interface{}{
								&PortRangeProperty{
									FromPort: jsii.Number(123),
									ToPort: jsii.Number(123),
								},
							},
							Sources: []interface{}{
								&AddressProperty{
									AddressDefinition: jsii.String("addressDefinition"),
								},
							},
							TcpFlags: []interface{}{
								&TCPFlagFieldProperty{
									Flags: []*string{
										jsii.String("flags"),
									},

									// the properties below are optional
									Masks: []*string{
										jsii.String("masks"),
									},
								},
							},
						},
					},
				},
			},

			// the properties below are optional
			CustomActions: []interface{}{
				&CustomActionProperty{
					ActionDefinition: &ActionDefinitionProperty{
						PublishMetricAction: &PublishMetricActionProperty{
							Dimensions: []interface{}{
								&DimensionProperty{
									Value: jsii.String("value"),
								},
							},
						},
					},
					ActionName: jsii.String("actionName"),
				},
			},
		},
	},

	// the properties below are optional
	ReferenceSets: &ReferenceSetsProperty{
		IpSetReferences: map[string]interface{}{
			"ipSetReferencesKey": map[string]*string{
				"referenceArn": jsii.String("referenceArn"),
			},
		},
	},
	RuleVariables: &RuleVariablesProperty{
		IpSets: map[string]interface{}{
			"ipSetsKey": map[string][]*string{
				"definition": []*string{
					jsii.String("definition"),
				},
			},
		},
		PortSets: map[string]interface{}{
			"portSetsKey": &PortSetProperty{
				"definition": []*string{
					jsii.String("definition"),
				},
			},
		},
	},
	StatefulRuleOptions: &StatefulRuleOptionsProperty{
		RuleOrder: jsii.String("ruleOrder"),
	},
}

Properties ​

referenceSetsoptionalIResolvable | CfnRuleGroup.ReferenceSetsPropertyreference_setsoptionaltyping.Union[IResolvable, ReferenceSetsProperty]referenceSetsoptionalIResolvableReferenceSetsoptionalIResolvableReferenceSetsoptionalinterface{}#
The reference sets for the stateful rule group.
rulesSourceIResolvable | CfnRuleGroup.RulesSourcePropertyrules_sourcetyping.Union[IResolvable, RulesSourceProperty]rulesSourceIResolvableRulesSourceIResolvableRulesSourceinterface{}required#
The stateful rules or stateless rules for the rule group.
ruleVariablesoptionalIResolvable | CfnRuleGroup.RuleVariablesPropertyrule_variablesoptionaltyping.Union[IResolvable, RuleVariablesProperty]ruleVariablesoptionalIResolvableRuleVariablesoptionalIResolvableRuleVariablesoptionalinterface{}#
Settings that are available for use in the rules in the rule group.

You can only use these for stateful rule groups.

statefulRuleOptionsoptionalIResolvable | CfnRuleGroup.StatefulRuleOptionsPropertystateful_rule_optionsoptionaltyping.Union[IResolvable, StatefulRuleOptionsProperty]statefulRuleOptionsoptionalIResolvableStatefulRuleOptionsoptionalIResolvableStatefulRuleOptionsoptionalinterface{}#
Additional options governing how Network Firewall handles stateful rules.
notes

The policies where you use your stateful rule group must have stateful rule options settings that are compatible with these settings. Some limitations apply; for more information, see Strict evaluation order in the AWS Network Firewall Developer Guide .