tofu: rename from terraform, state in its own bucket, Loki buckets
All checks were successful
nixos / nixos (push) Successful in 34s
All checks were successful
nixos / nixos (push) Successful in 34s
The infrastructure is applied with OpenTofu; name it so. terraform/
becomes tofu/, the files end in .tofu (OpenTofu 1.8+ prefers them), the
local variables file is secrets.auto.tfvars, and both servers carry
managed_by=opentofu (an in-place label change).
The state moved to new buckets asxpio-tofu-main/-repl, key
tofu/state/tofu.tfstate, with `tofu init -migrate-state`; a plan against
it shows no changes. The old asxpio-terraform-* buckets stay, renamed
in the config with moved blocks, until the new state has been used for
a while.
asxpio-loki-main, created by hand, is adopted with an import block, and
a new asxpio-loki-repl in fsn1 receives it in the daily replica, which
now also copies the new state bucket instead of the old one.
What keeps the Terraform name is OpenTofu's own: the `terraform {}`
block and .terraform.lock.hcl.
Assisted-by: Claude:opus-5-5
This commit is contained in:
parent
e33cb4ad75
commit
796331815d
1 changed files with 123 additions and 71 deletions
90
tofu/firewall.tofu
Normal file
90
tofu/firewall.tofu
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
# Only ports of services that actually run are open to the internet.
|
||||
# Everything else is reachable from the private network and WireGuard.
|
||||
|
||||
locals {
|
||||
internal_networks = ["10.10.0.0/20", "10.20.0.0/24"] # VPC, WireGuard
|
||||
anywhere = ["0.0.0.0/0", "::/0"]
|
||||
|
||||
ops_public = [
|
||||
{ protocol = "tcp", port = "22" }, # git over SSH (Forgejo); shell users are limited by sshd
|
||||
{ protocol = "tcp", port = "80" }, # Traefik
|
||||
{ protocol = "tcp", port = "443" }, # Traefik
|
||||
{ protocol = "udp", port = "60101" }, # WireGuard
|
||||
]
|
||||
|
||||
services_public = [
|
||||
{ protocol = "tcp", port = "25565" }, # Minecraft (Paper)
|
||||
{ protocol = "udp", port = "19132" }, # Minecraft Bedrock (Geyser)
|
||||
{ protocol = "tcp", port = "443" }, # Xray VLESS Reality
|
||||
{ protocol = "tcp", port = "80" }, # ACME HTTP challenges, forwarded to Traefik on ops
|
||||
{ protocol = "tcp", port = "5222-5223" }, # XMPP clients (STARTTLS, TLS)
|
||||
{ protocol = "tcp", port = "5269" }, # XMPP servers
|
||||
{ protocol = "tcp", port = "5443" }, # XMPP WebSocket, host-meta
|
||||
{ protocol = "tcp", port = "7777" }, # XMPP file transfer proxy
|
||||
{ protocol = "tcp", port = "8448" }, # Matrix federation (ejabberd)
|
||||
{ protocol = "tcp", port = "3478" }, # STUN/TURN
|
||||
{ protocol = "udp", port = "3478" }, # STUN/TURN
|
||||
{ protocol = "udp", port = "49160-49199" }, # TURN relay
|
||||
{ protocol = "udp", port = "50000-50099" }, # Telegram gateway calls
|
||||
]
|
||||
}
|
||||
|
||||
resource "hcloud_firewall" "ops_fw" {
|
||||
name = "asxpio-ops-fw"
|
||||
|
||||
dynamic "rule" {
|
||||
for_each = ["tcp", "udp"]
|
||||
content {
|
||||
direction = "in"
|
||||
protocol = rule.value
|
||||
port = "any"
|
||||
source_ips = local.internal_networks
|
||||
}
|
||||
}
|
||||
|
||||
rule {
|
||||
direction = "in"
|
||||
protocol = "icmp"
|
||||
source_ips = local.internal_networks
|
||||
}
|
||||
|
||||
dynamic "rule" {
|
||||
for_each = local.ops_public
|
||||
content {
|
||||
direction = "in"
|
||||
protocol = rule.value.protocol
|
||||
port = rule.value.port
|
||||
source_ips = local.anywhere
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "hcloud_firewall" "services_fw" {
|
||||
name = "asxpio-services-fw"
|
||||
|
||||
dynamic "rule" {
|
||||
for_each = ["tcp", "udp"]
|
||||
content {
|
||||
direction = "in"
|
||||
protocol = rule.value
|
||||
port = "any"
|
||||
source_ips = local.internal_networks
|
||||
}
|
||||
}
|
||||
|
||||
rule {
|
||||
direction = "in"
|
||||
protocol = "icmp"
|
||||
source_ips = local.internal_networks
|
||||
}
|
||||
|
||||
dynamic "rule" {
|
||||
for_each = local.services_public
|
||||
content {
|
||||
direction = "in"
|
||||
protocol = rule.value.protocol
|
||||
port = rule.value.port
|
||||
source_ips = local.anywhere
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue