terraform {
  required_version = ">= 1.0"

  required_providers {
    local = {
      source  = "hashicorp/local"
      version = "~> 2.8.0"
    }

    proxmox = {
      source  = "bpg/proxmox"
      version = "~> 0.103.0"
    }
  }
}

locals {
  proxmox_endpoint_normalized = format(
    "%s/",
    trimsuffix(replace(trimspace(var.proxmox_endpoint), "/api2/json", ""), "/")
  )
}

provider "proxmox" {
  endpoint  = local.proxmox_endpoint_normalized
  api_token = "${var.proxmox_api_token_id}=${var.proxmox_api_token_secret}"
  insecure  = var.proxmox_insecure
}
