This template sets up a stateful rule group using rule variables and Suricata format rules in AWS Network Firewall.

Terraform Template

resource "aws_networkfirewall_rule_group" "example" {
  capacity = 100
  name = "example"

  rule_group {

    rule_variables {

      ip_sets {

        ip_set {
          definition = ["10.0.0.0/16", "10.0.1.0/24", "192.168.0.0/16"]
        }
        key = "WEBSERVERS_HOSTS"
      }

      ip_sets {

        ip_set {
          definition = ["1.2.3.4/32"]
        }
        key = "EXTERNAL_HOST"
      }

      port_sets {
        key = "HTTP_PORTS"

        port_set {
          definition = ["443", "80"]
        }
      }
    }

    rules_source {
      rules_string = file("suricata_rules_file")
    }
  }

  tags = {
    Tag1 = "Value1"
    Tag2 = "Value2"
  }
  type = "STATEFUL"
}