feat(terraform): create hetzner server and apex A record

This commit is contained in:
Noel Sabia committed 2026-10-27 14:30:59 +01:00
1 parent 3335482efc
commit 8e0c1a8796
6 files changed
+96 -26

No files matched your search

+18 -15
View File
@@ -20,12 +20,14 @@ on an empty machine. See `OKF_CV_Website/architecture/terraform.md`.
## Steps
### 1. Server source
### 1. Server source — done
Decide the two open questions above. Write them into this file so later steps
have a fixed target.
`main.tf` creates `server0` as a Hetzner `hcloud_server` (`cx22`, `ubuntu-24.04`)
and registers `~/.ssh/cv_infra.pub` as an `hcloud_ssh_key`, so the key is in
`authorized_keys` before the machine boots. `terraform.md` and `README.md` still
describe `server_host` as an input; they need updating.
Check: one sentence answers "what does `apply` create?".
Check: `terraform output server_ip` returns the address.
### 2. SSH key — done
@@ -34,11 +36,10 @@ server during creation (step 6), not after.
Check: `ssh-keygen -y -f ~/.ssh/cv_infra` prints the public key.
### 3. Provider and versions
### 3. Provider and versions — done
Uncomment `versions.tf`, set `required_version` and the provider(s), run
`terraform init`. Commit `.terraform.lock.hcl` is currently ignored — decide
whether that stays.
`versions.tf` pins `cloudflare` 5.28.1 and `hcloud` 1.70.2; init and validate
pass. `required_version` and a `null` provider still need adding before step 7.
Check: `terraform init` succeeds, `.terraform.lock.hcl` exists.
@@ -50,20 +51,22 @@ Copy `terraform.tfvars.example` to `terraform.tfvars`, fill `server_host`,
Check: `terraform validate` passes.
### 5. DNS first
### 5. DNS — written
Write `dns.tf`: one `cloudflare_record` for the apex A record. Smallest real
resource, and it exercises provider, token and zone ID with no server involved.
`dns.tf` creates `cloudflare_dns_record.apex` from
`hcloud_server.server0.ipv4_address`, so the record can only be created after
the server — one `apply` does both, in order. `proxied = false` is required for
Caddy's ACME challenge.
Check: `terraform apply` creates the record, `dig +short <domain>` returns the
server IP.
### 6. Server creation
### 6. Server creation — written
Add the server resource with the SSH public key attached at creation.
`main.tf` creates the server with the SSH public key attached at creation.
Check: `terraform apply` creates it, `ssh -i ~/.ssh/cv_infra <user>@<host>`
works without a password.
Check: `terraform apply` creates it, `terraform output ssh_command` works
without a password.
### 7. Connection skeleton