Skip to content

dhoppeIT/terraform-hcloud-firewall

Repository files navigation

terraform-hcloud-firewall

Terraform module to manage the following Hetzner Cloud resource:

  • hcloud_firewall

Graph

Graph

Usage

Copy and paste into your Terraform configuration, insert the variables and run terraform init:

module "hcloud_firewall" {
  source  = "dhoppeIT/firewall/hcloud"
  version = "~> 0.1"

  name = "default"
  rule = [
    {
      direction  = "in"
      protocol   = "icmp"
      source_ips = ["0.0.0.0/0"]
    },
    {
      direction  = "in"
      protocol   = "tcp"
      port       = "22"
      source_ips = ["0.0.0.0/0"]
    },
    {
      direction       = "out"
      protocol        = "icmp"
      destination_ips = ["0.0.0.0/0"]
    },
    {
      direction       = "out"
      protocol        = "tcp"
      port            = "53"
      destination_ips = ["0.0.0.0/0"]
    },
    {
      direction       = "out"
      protocol        = "udp"
      port            = "53"
      destination_ips = ["0.0.0.0/0"]
    },
    {
      direction       = "out"
      protocol        = "tcp"
      port            = "80"
      destination_ips = ["0.0.0.0/0"]
    },
    {
      direction       = "out"
      protocol        = "tcp"
      port            = "443"
      destination_ips = ["0.0.0.0/0"]
    }
  ]
}

Requirements

Name Version
terraform >= 1.3
hcloud ~> 1.0

Providers

Name Version
hcloud 1.36.0

Modules

No modules.

Resources

Name Type
hcloud_firewall.default resource

Inputs

Name Description Type Default Required
apply_to Resources the firewall should be assigned to
list(object({
label_selector = optional(string)
server = optional(number)
}))
[] no
labels User-defined labels (key-value pairs) should be created with map(string) {} no
name Name of the Firewall string null no
rule Configuration of a Rule from this Firewall
list(object({
direction = string
protocol = string
port = optional(string)
source_ips = optional(list(string))
destination_ips = optional(list(string))
description = optional(string)
}))
[] no

Outputs

Name Description
id Unique ID of the Firewall
name Name of the Firewall

Authors

Created and maintained by Dennis Hoppe.

License

Apache 2 licensed. See LICENSE for full details.