Terraform provider reference / resources / server_firewall

fiberax_server_firewall (Resource)

Firewall of a server. ONE resource per server, and the rule set is a field of it.

The rules are replaced as a whole; you cannot add or remove a single one. The reason lies in the nature of the thing: inside the platform a rule is addressed by its number in the list, and that number shifts when a neighbouring rule is deleted - such an identifier can be neither stored nor imported. Replacing the whole set also gives what cannot be expressed otherwise: ORDER. The rules are read from top to bottom, and the first matching rule wins.

Filtering applies to the server's public card only. That is why a rule names no card at all, and a server with no public card cannot enable it - the rules can still be stored while it is off.

The resource has no create and no delete: a server always has a firewall. Destroying the resource DOES NOT TOUCH the platform - the details are in the destroy behaviour described below.

Example Usage

# The server firewall. ONE resource per server; rules are its field, replaced as a whole.
#
# Rule order MATTERS: the first matching rule wins.
resource "fiberax_server_firewall" "app" {
  server_id = fiberax_server.app.id
  enabled   = true

  policy_in  = "drop"   # anything not allowed below is dropped
  policy_out = "accept" # outbound traffic is not restricted

  rules = [
    {
      direction   = "in"
      action      = "accept"
      macro       = "ssh"
      source      = "203.0.113.0/24" # from the office only
      description = "management"
    },
    {
      direction        = "in"
      action           = "accept"
      protocol         = "tcp"
      destination_port = "80,443"
      description      = "web"
    },
    {
      # A rule can stay in the set switched off: it does nothing,
      # but it is not lost either.
      direction        = "in"
      action           = "accept"
      protocol         = "tcp"
      destination_port = "5432"
      enabled          = false
      description      = "database, closed for now"
    },
  ]
}

Schema

Required

The flag belongs to the SERVER, not to the cards. When you switch it on, the platform also marks the public cards that exist AT THAT MOMENT. A public card added later gets no mark and stays UNFILTERED - while the flag goes on saying it is on and shows no drift.

So after you add a public card to a server, apply the policy again: a change to any field of this resource marks that card too. The simplest way is to hold enabled switched off for one run and then switch it back on.

The list is REQUIRED, and that is a safeguard: a request with no rules means remove them all, and a forgotten field would cost far too much. To have no rules at all, write an empty list explicitly. (see below for nested schema)

Optional

This API does not hand out the log itself: a log line carries the platform's internal interface names. It is read in the client area, and the level is declared here because the state of the firewall has to be described as a whole. An omitted field means nolog.

An omitted field means drop; it does not mean leave it as it is. That is how the operation itself works: it sets the WHOLE state of the firewall, and a field that does not arrive is taken by the platform from its own defaults. So the default is declared here - then the value is visible in the plan BEFORE you approve it, instead of being substituted silently.

Nested Schema for rules

Required:

Optional:

Control characters are refused, and that is not cosmetic: the note travels into the firewall configuration AS TEXT, so a line break inside it turns into a separate REAL rule. A leading hash is refused separately - it hides the rule from the listing.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

# The import ID is the server ID: a server has exactly one firewall.
terraform import fiberax_server_firewall.app 10867

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