Terraform provider reference / resources / router_firewall_rule

fiberax_router_firewall_rule (Resource)

One access rule of a ROUTER's firewall.

Unlike fiberax_server_firewall, where the whole rule set is one resource, a router rule is a resource of its own: it is addressed by its number on the router (priority), and that number does not shift when a neighbouring rule is deleted. Rules are checked in ascending number order and the first matching rule wins.

Ordering across several rules is expressed with priority. Terraform creates resources in parallel, so rules created without a number get the next free numbers in an arbitrary order. Give each rule a priority when the order matters.

Rules created inside the router by hand are visible too (editable = false, extra non-empty): they can be imported and deleted, but not changed.

The first drop or reject rule also switches the router to stateful filtering (replies to established connections pass); that is a property of the router, not of the rule.

Example Usage

# Access rules of a ROUTER. Each rule is a resource of its own, addressed by its
# number on the router; rules are checked in ascending number order and the
# first matching rule wins.
#
# Give rules a priority when the order matters: Terraform creates resources in
# parallel, and rules without a number get free numbers in an arbitrary order.
resource "fiberax_router_firewall_rule" "ssh_from_office" {
  server_id        = fiberax_server.router.id
  priority         = 2010
  action           = "accept"
  protocol         = "tcp"
  interface        = "eth0" # the public side of the router
  source           = "203.0.113.0/24"
  destination_port = "22"
  description      = "ssh from the office"
}

resource "fiberax_router_firewall_rule" "web" {
  server_id        = fiberax_server.router.id
  priority         = 2020
  action           = "accept"
  protocol         = "tcp"
  interface        = "eth0"
  destination_port = "80,443"
  description      = "web"
}

# The first drop or reject rule also switches the router to stateful filtering,
# so replies to connections allowed above keep passing.
resource "fiberax_router_firewall_rule" "drop_the_rest" {
  server_id   = fiberax_server.router.id
  priority    = 2100
  action      = "drop"
  interface   = "eth0"
  description = "everything else from the internet"
}

Schema

Required

Optional

The number cannot be changed on an existing rule, so setting a different one recreates the resource. A number freed by a delete is reused by the next create.

Read-Only

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# The import ID is the router's server ID and the rule number, separated by a comma.
terraform import fiberax_router_firewall_rule.ssh_from_office 11102,2010

Generated from the provider schema for version 0.3.0. How to install the provider: Terraform provider.