Add Terraform for Hetzner Cloud CX53 migration#1
Merged
Conversation
Provision a CX53 VPS (16 vCPU, 32GB RAM, 320GB NVMe) to replace the current AX42-U dedicated server, reducing monthly cost from ~€68 to ~€23. - Terraform: hcloud server + firewall + Cloudflare DNS records - CI: plan on PR, apply on merge (S3/Wasabi state backend) - MySQL config tuned for 32GB RAM (20GB buffer pool, lower I/O threads) - Setup script adds 4GB swap file for VPS Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Terraform Plan OutputClick to expandTerraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# cloudflare_record.apex will be created
+ resource "cloudflare_record" "apex" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "akatsuki.gg"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "A"
+ value = (known after apply)
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["a"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "a"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["air_conditioning"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "air_conditioning"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["assets"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "assets"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["b"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "b"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["beatmaps"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "beatmaps"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["c"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "c"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["difficulty"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "difficulty"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["old"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "old"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["osu"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "osu"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["payments"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "payments"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["performance"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "performance"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["relax"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "relax"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["rework"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "rework"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["reworks"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "reworks"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["s"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "s"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["vault"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "vault"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.cname["www"] will be created
+ resource "cloudflare_record" "cname" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "www"
+ proxiable = (known after apply)
+ proxied = true
+ ttl = 1
+ type = "CNAME"
+ value = "akatsuki.gg"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.mx_alt1 will be created
+ resource "cloudflare_record" "mx_alt1" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "akatsuki.gg"
+ priority = 5
+ proxiable = (known after apply)
+ proxied = false
+ ttl = 1
+ type = "MX"
+ value = "alt1.aspmx.l.google.com"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.mx_alt2 will be created
+ resource "cloudflare_record" "mx_alt2" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "akatsuki.gg"
+ priority = 5
+ proxiable = (known after apply)
+ proxied = false
+ ttl = 1
+ type = "MX"
+ value = "alt2.aspmx.l.google.com"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.mx_alt3 will be created
+ resource "cloudflare_record" "mx_alt3" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "akatsuki.gg"
+ priority = 10
+ proxiable = (known after apply)
+ proxied = false
+ ttl = 1
+ type = "MX"
+ value = "alt3.aspmx.l.google.com"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.mx_alt4 will be created
+ resource "cloudflare_record" "mx_alt4" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "akatsuki.gg"
+ priority = 10
+ proxiable = (known after apply)
+ proxied = false
+ ttl = 1
+ type = "MX"
+ value = "alt4.aspmx.l.google.com"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.mx_primary will be created
+ resource "cloudflare_record" "mx_primary" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "akatsuki.gg"
+ priority = 1
+ proxiable = (known after apply)
+ proxied = false
+ ttl = 1
+ type = "MX"
+ value = "aspmx.l.google.com"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# cloudflare_record.mx_verification will be created
+ resource "cloudflare_record" "mx_verification" {
+ allow_overwrite = false
+ content = (known after apply)
+ created_on = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ metadata = (known after apply)
+ modified_on = (known after apply)
+ name = "akatsuki.gg"
+ priority = 15
+ proxiable = (known after apply)
+ proxied = false
+ ttl = 1
+ type = "MX"
+ value = "3h5azgn53tixa3a2yxyqkgyethll22hdjl7jj5jshsfw2wpalkhq.mx-verification.google.com"
+ zone_id = "18875b98b47e13a11f76f5795912453f"
}
# hcloud_firewall.production will be created
+ resource "hcloud_firewall" "production" {
+ id = (known after apply)
+ labels = (known after apply)
+ name = "akatsuki-production"
+ rule {
+ description = "Grafana via Tailscale"
+ destination_ips = []
+ direction = "in"
+ port = "3001"
+ protocol = "tcp"
+ source_ips = [
+ "100.64.0.0/10",
]
}
+ rule {
+ description = "HTTP from Cloudflare"
+ destination_ips = []
+ direction = "in"
+ port = "80"
+ protocol = "tcp"
+ source_ips = [
+ "103.21.244.0/22",
+ "103.22.200.0/22",
+ "103.31.4.0/22",
+ "104.16.0.0/13",
+ "104.24.0.0/14",
+ "108.162.192.0/18",
+ "131.0.72.0/22",
+ "141.101.64.0/18",
+ "162.158.0.0/15",
+ "172.64.0.0/13",
+ "173.245.48.0/20",
+ "188.114.96.0/20",
+ "190.93.240.0/20",
+ "197.234.240.0/22",
+ "198.41.128.0/17",
]
}
+ rule {
+ description = "HTTPS from Cloudflare"
+ destination_ips = []
+ direction = "in"
+ port = "443"
+ protocol = "tcp"
+ source_ips = [
+ "103.21.244.0/22",
+ "103.22.200.0/22",
+ "103.31.4.0/22",
+ "104.16.0.0/13",
+ "104.24.0.0/14",
+ "108.162.192.0/18",
+ "131.0.72.0/22",
+ "141.101.64.0/18",
+ "162.158.0.0/15",
+ "172.64.0.0/13",
+ "173.245.48.0/20",
+ "188.114.96.0/20",
+ "190.93.240.0/20",
+ "197.234.240.0/22",
+ "198.41.128.0/17",
]
}
+ rule {
+ description = "SSH via Tailscale"
+ destination_ips = []
+ direction = "in"
+ port = "22"
+ protocol = "tcp"
+ source_ips = [
+ "100.64.0.0/10",
]
}
+ rule {
+ description = "Vault via Tailscale"
+ destination_ips = []
+ direction = "in"
+ port = "8200"
+ protocol = "tcp"
+ source_ips = [
+ "100.64.0.0/10",
]
}
}
# hcloud_server.production will be created
+ resource "hcloud_server" "production" {
+ allow_deprecated_images = false
+ backup_window = (known after apply)
+ backups = false
+ datacenter = (known after apply)
+ delete_protection = false
+ firewall_ids = (known after apply)
+ id = (known after apply)
+ ignore_remote_firewall_ids = false
+ image = "ubuntu-24.04"
+ ipv4_address = (known after apply)
+ ipv6_address = (known after apply)
+ ipv6_network = (known after apply)
+ keep_disk = false
+ labels = {
+ "environment" = "production"
+ "project" = "akatsuki"
}
+ location = "fsn1"
+ name = "akatsuki-production"
+ primary_disk_size = (known after apply)
+ rebuild_protection = false
+ server_type = "cx53"
+ shutdown_before_deletion = false
+ ssh_keys = (known after apply)
+ status = (known after apply)
}
# hcloud_ssh_key.deploy will be created
+ resource "hcloud_ssh_key" "deploy" {
+ fingerprint = (known after apply)
+ id = (known after apply)
+ labels = {}
+ name = "akatsuki-deploy"
+ public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE7rhmtf85uc73M3S+HEEqbCLWJeMzRSfUgqzdcQC4yz cmyui@Joshs-MacBook-Pro.local"
}
Plan: 27 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ server_ip = (known after apply)
+ server_status = (known after apply) |
Phase 1 only provisions the Hetzner server + firewall. Cloudflare DNS will be imported and updated in phase 2 after data migration is complete. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Terraform Plan OutputClick to expandTerraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# hcloud_firewall.production will be created
+ resource "hcloud_firewall" "production" {
+ id = (known after apply)
+ labels = (known after apply)
+ name = "akatsuki-production"
+ rule {
+ description = "Grafana via Tailscale"
+ destination_ips = []
+ direction = "in"
+ port = "3001"
+ protocol = "tcp"
+ source_ips = [
+ "100.64.0.0/10",
]
}
+ rule {
+ description = "HTTP from Cloudflare"
+ destination_ips = []
+ direction = "in"
+ port = "80"
+ protocol = "tcp"
+ source_ips = [
+ "103.21.244.0/22",
+ "103.22.200.0/22",
+ "103.31.4.0/22",
+ "104.16.0.0/13",
+ "104.24.0.0/14",
+ "108.162.192.0/18",
+ "131.0.72.0/22",
+ "141.101.64.0/18",
+ "162.158.0.0/15",
+ "172.64.0.0/13",
+ "173.245.48.0/20",
+ "188.114.96.0/20",
+ "190.93.240.0/20",
+ "197.234.240.0/22",
+ "198.41.128.0/17",
]
}
+ rule {
+ description = "HTTPS from Cloudflare"
+ destination_ips = []
+ direction = "in"
+ port = "443"
+ protocol = "tcp"
+ source_ips = [
+ "103.21.244.0/22",
+ "103.22.200.0/22",
+ "103.31.4.0/22",
+ "104.16.0.0/13",
+ "104.24.0.0/14",
+ "108.162.192.0/18",
+ "131.0.72.0/22",
+ "141.101.64.0/18",
+ "162.158.0.0/15",
+ "172.64.0.0/13",
+ "173.245.48.0/20",
+ "188.114.96.0/20",
+ "190.93.240.0/20",
+ "197.234.240.0/22",
+ "198.41.128.0/17",
]
}
+ rule {
+ description = "SSH via Tailscale"
+ destination_ips = []
+ direction = "in"
+ port = "22"
+ protocol = "tcp"
+ source_ips = [
+ "100.64.0.0/10",
]
}
+ rule {
+ description = "Vault via Tailscale"
+ destination_ips = []
+ direction = "in"
+ port = "8200"
+ protocol = "tcp"
+ source_ips = [
+ "100.64.0.0/10",
]
}
}
# hcloud_server.production will be created
+ resource "hcloud_server" "production" {
+ allow_deprecated_images = false
+ backup_window = (known after apply)
+ backups = false
+ datacenter = (known after apply)
+ delete_protection = false
+ firewall_ids = (known after apply)
+ id = (known after apply)
+ ignore_remote_firewall_ids = false
+ image = "ubuntu-24.04"
+ ipv4_address = (known after apply)
+ ipv6_address = (known after apply)
+ ipv6_network = (known after apply)
+ keep_disk = false
+ labels = {
+ "environment" = "production"
+ "project" = "akatsuki"
}
+ location = "fsn1"
+ name = "akatsuki-production"
+ primary_disk_size = (known after apply)
+ rebuild_protection = false
+ server_type = "cx53"
+ shutdown_before_deletion = false
+ ssh_keys = (known after apply)
+ status = (known after apply)
}
# hcloud_ssh_key.deploy will be created
+ resource "hcloud_ssh_key" "deploy" {
+ fingerprint = (known after apply)
+ id = (known after apply)
+ labels = {}
+ name = "akatsuki-deploy"
+ public_key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIE7rhmtf85uc73M3S+HEEqbCLWJeMzRSfUgqzdcQC4yz cmyui@Joshs-MacBook-Pro.local"
}
Plan: 3 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ server_ip = (known after apply)
+ server_status = (known after apply) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
terraform planon PR,terraform applyon merge to mainReplaces the current AX42-U dedicated server (~€68/mo post-April) with a CX53 VPS (~€23/mo), saving ~€540/year. CPU is massively underutilized (<2%) so shared vCPU is fine.
Migration plan
setup.shto bootstrapdocker compose pull && docker compose up -dNote: Cloudflare DNS records are included — merging will cut over DNS immediately. Consider commenting out
cloudflare.tfresources for initial apply if you want to migrate data first.Test plan
terraform planoutput in CI comment below🤖 Generated with Claude Code