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
105 lines
3.5 KiB
Markdown
105 lines
3.5 KiB
Markdown
# ASXP.IO Infrastructure
|
|
|
|
Hetzner Cloud infrastructure, managed with [OpenTofu](https://opentofu.org)
|
|
(`tofu`; the dev shell of `../nixos` has it). The files are plain HCL and
|
|
the state lives in Object Storage (`asxpio-tofu-main`, key
|
|
`tofu/state/tofu.tfstate`); `.terraform.lock.hcl` (OpenTofu keeps that
|
|
name) pins the providers and is committed. Files end in `.tofu`.
|
|
|
|
## Servers
|
|
|
|
- **asxpio-ops** (CX23: 2 vCPU, 4GB) - Traefik, Forgejo, app stacks
|
|
- **asxpio-services** (CX43: 8 vCPU, 16GB) - CI runner, game servers, SillyTavern
|
|
|
|
Both have delete and rebuild protection. Hetzner's server backups are
|
|
off; restic backs up the data instead (see ../README.md).
|
|
|
|
Both servers carry `prevent_destroy` and ignore changes to `user_data`,
|
|
`image` and `ssh_keys`, because hcloud would replace a running server
|
|
when those change.
|
|
|
|
A new server boots Debian and converts itself to NixOS: its cloud-init
|
|
(`cloud-init/nixos.yaml.tftpl`, one template for both) runs a pinned
|
|
nixos-infect and reboots into a bare NixOS, about three minutes after
|
|
creation. The system's configuration then comes from `../nixos`. Edits
|
|
to the template reach a server only when it is created or rebuilt in
|
|
place; both procedures are in `../nixos/README.md`.
|
|
|
|
## Storage (S3-compatible)
|
|
|
|
**OpenTofu state:**
|
|
- asxpio-tofu-main (hel1), replicated daily to asxpio-tofu-repl (fsn1)
|
|
- asxpio-terraform-main / -repl: where the state lived until 2026-11-17;
|
|
kept for now (`legacy_state_*`), to be emptied and removed
|
|
|
|
**Backups:**
|
|
- asxpio-backups-main (hel1), replicated to asxpio-backups-repl (fsn1),
|
|
except `restic/` (restic writes both itself)
|
|
|
|
**Logs:**
|
|
- asxpio-loki-main (hel1): Loki's chunks, replicated to asxpio-loki-repl
|
|
(fsn1)
|
|
|
|
The daily replica runs on asxpio-services
|
|
(`nixos/hosts/asxpio-services/replica.nix`).
|
|
|
|
## DNS
|
|
|
|
`dns.tofu` holds the zones asxp.io and czsk.it (Hetzner DNS, this project)
|
|
and every record set except SOA and NS. Our servers' records reference
|
|
`hcloud_server`, so moving a service is one edit.
|
|
|
|
All record sets are change-protected except the test XMPP servers'
|
|
(`prosody`, `ejabberd`, `anotherim`); both zones are delete-protected.
|
|
To change a protected record set, apply twice: first with the set
|
|
excluded from protection, then with the new value. Hand edits in the
|
|
console show up as drift in `tofu plan`.
|
|
|
|
## Network
|
|
|
|
- VPC: 10.10.0.0/20
|
|
- WireGuard VPN: 10.20.0.0/24
|
|
- IPv4 + IPv6 enabled
|
|
|
|
## Cost
|
|
|
|
| Item | Monthly |
|
|
|------|---------|
|
|
| ops CX23 | €3.99 |
|
|
| services CX43 | €11.99 |
|
|
| IPv4 (2x) | €1.00 |
|
|
| S3 (1TB) | €6.49 |
|
|
| S3 1TB Traffic | €1.00 |
|
|
| **Total** | **€24.47** |
|
|
|
|
Prices are net, as billed in November 2026 (0% VAT).
|
|
|
|
Both servers are billed below the current list price (€5.49 and €15.99).
|
|
A deleted and recreated server gets the list price, so reinstall or
|
|
rebuild in place and never recreate. `prevent_destroy` and Hetzner's
|
|
delete protection guard against it.
|
|
|
|
## Setup
|
|
|
|
```bash
|
|
cp secrets.auto.tfvars.example secrets.auto.tfvars # token and Object Storage keys
|
|
export AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... # state bucket
|
|
tofu init
|
|
tofu plan
|
|
tofu apply
|
|
```
|
|
|
|
In a new project the state bucket does not exist yet: comment out the
|
|
`backend "s3"` block in `providers.tofu` for the first apply, restore it,
|
|
then `tofu init -migrate-state`.
|
|
|
|
|
|
## Files
|
|
|
|
- `servers.tofu` - Server definitions, cloud-init variables
|
|
- `s3.tofu` - Object Storage buckets
|
|
- `vpc.tofu` - Private network
|
|
- `firewall.tofu` - Security rules
|
|
- `dns.tofu` - DNS zones and records
|
|
- `keys.tofu` - SSH keys
|
|
- `cloud-init/nixos.yaml.tftpl` - first boot: Debian to NixOS
|