From dd0351ad49a83c5319da68dec951cc0fd7623c80 Mon Sep 17 00:00:00 2001 From: alessandrovitali Date: Thu, 13 Aug 2026 13:23:05 +0200 Subject: [PATCH] feat: terraform configuration for classic VPS --- terraform/main.tf | 40 ++++++++++++++++++++++++++++++++++++++++ terraform/providers.tf | 14 ++++++++++++++ terraform/variables.tf | 30 ++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 terraform/main.tf create mode 100644 terraform/providers.tf create mode 100644 terraform/variables.tf diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 0000000..21f03d1 --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,40 @@ +# Fetch billing subsidiary details from your OVH account profile +data "ovh_me" "myaccount" {} + +# Provision the Classic VPS +resource "ovh_vps" "vps_1" { + display_name = "coolify" + + ovh_subsidiary = data.ovh_me.myaccount.ovh_subsidiary # Country of billing entity (e.g. "CH", "DE") + plan = [ + { + duration = "P1M" # Monthly subscription ("P1M") + plan_code = "vps-le-2-2-40" # Starter plan model (Adjust depending on current catalog) + pricing_mode = "default" + + # Datacenter configuration + configuration = [ + { + label = "vps_datacenter" + value = "LIM" # Limburg (DE) + }, + { + label = "vps_os" + value = "ubuntu-22.04" + } + ] + } + ] + + public_ssh_key = var.ssh_public_key +} + +# The public IP of a classic VPS must be retrieved via a data source after delivery +data "ovh_vps" "vps_1" { + service_name = ovh_vps.vps_1.service_name +} + +output "vps_public_ip" { + value = tolist(data.ovh_vps.vps_1.ips)[0] + description = "The public IP address of VPS-1" +} diff --git a/terraform/providers.tf b/terraform/providers.tf new file mode 100644 index 0000000..9f70ab6 --- /dev/null +++ b/terraform/providers.tf @@ -0,0 +1,14 @@ +terraform { + required_providers { + ovh = { + source = "ovh/ovh" + } + } +} + +provider "ovh" { + endpoint = var.ovh_endpoint + application_key = var.ovh_application_key + application_secret = var.ovh_application_secret + consumer_key = var.ovh_consumer_key +} diff --git a/terraform/variables.tf b/terraform/variables.tf new file mode 100644 index 0000000..6c945ae --- /dev/null +++ b/terraform/variables.tf @@ -0,0 +1,30 @@ +variable "ovh_endpoint" { + type = string + description = "The OVH API endpoint" + default = "ovh-eu" +} + +variable "ovh_application_key" { + type = string + sensitive = true +} + +variable "ovh_application_secret" { + type = string + sensitive = true +} + +variable "ovh_consumer_key" { + type = string + sensitive = true +} + +variable "ovh_project_id" { + type = string + description = "The OVH Public Cloud Project ID (Service Name)" +} + +variable "ssh_public_key" { + type = string + description = "The public SSH key to install on the VM" +}