Skip to content
Odinex Cloud
Terraform providerReferenceResources

odinex_firewall

Manages a firewall. Rules and targets (apply_to) are updated in place. Use either apply_to blocks or odinex_firewall_attachment, not both.

Manages a firewall. Rules and targets (apply_to) are updated in place. Use either apply_to blocks or odinex_firewall_attachment, not both.

Example Usage

resource "odinex_firewall" "web" {
  name = "web"

  rule {
    direction  = "in"
    protocol   = "tcp"
    port       = "443"
    source_ips = ["0.0.0.0/0", "::/0"]
  }

  apply_to {
    label_selector = "role=web"
  }
}

Schema

Required

  • name (String) Name of the firewall.

Optional

  • apply_to (Block Set) Servers or label selectors the firewall applies to. Targets are only tracked while at least one apply_to block is configured (and are not imported); without blocks, targets managed by odinex_firewall_attachment are left alone.
  • labels (Map of String) User-defined labels (key/value pairs). Up to 64 pairs; keys and values up to 63 characters.
  • rule (Block Set) A firewall rule.

Read-Only

  • id (String) Unique ID of the resource.

Nested Schema for apply_to

Optional:

  • label_selector (String) Label selector, e.g. role=web.
  • server (Number) ID of a server.

Nested Schema for rule

Required:

  • direction (String) in or out.
  • protocol (String) tcp, udp, icmp, esp or gre.

Optional:

  • description (String) Description of the rule.
  • destination_ips (Set of String) Destination CIDRs; required for out rules.
  • port (String) Port (80) or range (1000-2000); required for tcp and udp.
  • source_ips (Set of String) Source CIDRs; required for in rules.

Import

Import is supported using the following syntax:

The terraform import command can be used, for example:

terraform import odinex_firewall.web 5

On this page