commit ad6af49bdefb38f01de8bc25f7f6e4710cde349f
Author: Chris Roberts <chris.roberts@learningunix.net>
Date: Mon, 18 May 2026 13:01:32 -0500
Initial commit
Diffstat:
6 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,5 @@
+terraform.tfvars
+.terraform/
+*.tfstate
+*.tfstate.backup
+.terraform.lock.hcl
diff --git a/README.md b/README.md
@@ -0,0 +1,16 @@
+# learningunix.net Infrastructure
+
+Infrastructure as code for [learningunix.net](https://learningunix.net). Provisions a Debian server on Hetzner Cloud.
+
+## Provisioning with OpenTofu
+
+Requires a Hetzner API token and an SSH key registered in your Hetzner account. Copy `terraform.tfvars.example` to `terraform.tfvars` and fill in your values. Do not commit `terraform.tfvars`.
+
+```
+cd infra/tofu
+tofu fmt
+tofu init
+tofu validate
+tofu plan
+tofu apply
+```
diff --git a/main.tf b/main.tf
@@ -0,0 +1,24 @@
+terraform {
+ required_providers {
+ hcloud = {
+ source = "hetznercloud/hcloud"
+ version = "~> 1.50"
+ }
+ }
+}
+
+
+
+provider "hcloud" {
+ token = var.hcloud_token
+}
+
+
+
+resource "hcloud_server" "main" {
+ name = "learningunix"
+ server_type = "cx23"
+ image = "debian-13"
+ location = var.location
+ ssh_keys = [var.ssh_key_name]
+}
diff --git a/outputs.tf b/outputs.tf
@@ -0,0 +1,4 @@
+
+output "server_ip" {
+ value = hcloud_server.main.ipv4_address
+}
diff --git a/terraform.tfvars.example b/terraform.tfvars.example
@@ -0,0 +1,2 @@
+hcloud_token = "your-api-token-here"
+ssh_key_name = "your-ssh-key-name"
diff --git a/variables.tf b/variables.tf
@@ -0,0 +1,11 @@
+variable "hcloud_token" {
+ sensitive = true
+}
+
+variable "ssh_key_name" {
+ description = "Name of the SSH key registered in your Hetzner account"
+}
+
+variable "location" {
+ default = "nbg1"
+}