iac/terraform/providers.tf
Sergei Poljanski c51522d371
terraform: install NixOS at first boot, run with OpenTofu
A new or rebuilt server should come up as NixOS without a manual
install. cloud-init now runs a pinned nixos-infect on the Debian image
and reboots into a bare NixOS; the system itself comes from nixos/.
One template replaces the two near-identical Debian cloud-init files.

nixos-infect's output needs three corrections on NixOS 26.05, written
to bootstrap.nix: the takeover of the old root only exists in the
scripted initrd, the IPv4 default route is never added without an
interface, and the private network gets no route. Found and verified
on throwaway servers.

The servers still ignore changes to user_data, so nothing happens to
the running ones. The new user_data output feeds a rebuild in place.

Switch to OpenTofu: same HCL and state, and it is free software in
nixpkgs. Commit the provider lock file so everyone gets the same
providers.

Assisted-by: Claude:fable-5-2
2026-11-16 22:59:58 +04:00

54 lines
1.5 KiB
HCL

# Run with OpenTofu (`tofu`, in the dev shell of ../nixos).
terraform {
required_version = ">= 1.8.0"
# S3 backend - comment this section if bucket not yet created
backend "s3" {
bucket = "asxpio-terraform-main"
key = "terraform/state/terraform.tfstate"
region = "hel1"
endpoint = "https://hel1.your-objectstorage.com"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_region_validation = true
skip_requesting_account_id = true
use_path_style = true
}
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
# 1.54 no longer reads a server's location from the Hetzner API and
# plans to replace every server because of it. Do not go below 1.70.
version = "~> 1.70"
}
minio = {
source = "aminueza/minio"
version = "~> 3.11"
}
}
}
provider "hcloud" {
token = var.hcloud_token
}
# MinIO provider for Helsinki (hel1) region
provider "minio" {
alias = "hel1"
minio_server = var.s3_endpoint_hel1
minio_user = var.s3_access_key
minio_password = var.s3_secret_key
minio_region = "hel1"
minio_ssl = true
}
# MinIO provider for Falkenstein (fsn1) region
provider "minio" {
alias = "fsn1"
minio_server = var.s3_endpoint_fsn1
minio_user = var.s3_access_key
minio_password = var.s3_secret_key
minio_region = "fsn1"
minio_ssl = true
}