pez-infra/terraform/hetzner/hetzner_firewall.tf
Rasmus "Pez" Wejlgaard 043c783361
Some checks are pending
Deploy (on merge) / Discover hosts (push) Waiting to run
Deploy (on merge) / Deploy → (push) Blocked by required conditions
Terraform / Plan (push) Waiting to run
Terraform / Apply (push) Blocked by required conditions
Grafana Cloud Migration (#94)
* Grafana Cloud migration, adding dashboards, fleet, alloy and synthetics

* modulize stuff now that we have multiple substantial things in here

* provider updates and new secrets

* remove grafana and prometheus from ansible
2026-05-04 13:40:30 +01:00

45 lines
1,001 B
HCL

locals {
all_ips = ["0.0.0.0/0", "::/0"]
machines = {
"nuremberg-a" = {
tcp_in = ["22", "25", "80", "110", "143", "443", "465", "587", "993", "995"]
server_id = hcloud_server.nuremberg-a.id
}
"helsinki-a" = {
tcp_in = ["22", "80", "443"]
server_id = hcloud_server.helsinki-a.id
}
}
}
resource "hcloud_firewall" "machine" {
for_each = local.machines
name = each.key
dynamic "rule" {
for_each = each.value.tcp_in
content {
direction = "in"
protocol = "tcp"
port = rule.value
source_ips = local.all_ips
}
}
dynamic "rule" {
for_each = ["tcp", "udp"]
content {
direction = "out"
protocol = rule.value
port = "any"
destination_ips = local.all_ips
}
}
}
resource "hcloud_firewall_attachment" "machine" {
for_each = local.machines
firewall_id = hcloud_firewall.machine[each.key].id
server_ids = [each.value.server_id]
}