From 5216c7a2ab4ac5356095e0f35c0b8ef8177e9f6f Mon Sep 17 00:00:00 2001 From: Ilya Kelim Date: Thu, 21 Nov 2024 15:38:19 +0200 Subject: [PATCH] Added "region" variable to control platform defaults (NFS Server); --- nfs-server/locals.tf | 16 ++++++++++++++++ nfs-server/main.tf | 2 ++ nfs-server/{nfs.tfvars => terraform.tfvars} | 1 + nfs-server/variables.tf | 17 +++++++++++++++++ 4 files changed, 36 insertions(+) rename nfs-server/{nfs.tfvars => terraform.tfvars} (88%) diff --git a/nfs-server/locals.tf b/nfs-server/locals.tf index ed79b470..2036a642 100644 --- a/nfs-server/locals.tf +++ b/nfs-server/locals.tf @@ -1,4 +1,20 @@ locals { ssh_public_key = var.ssh_public_key.key != null ? var.ssh_public_key.key : ( fileexists(var.ssh_public_key.path) ? file(var.ssh_public_key.path) : null) + + regions_default = { + eu-west1 = { + cpu_nodes_platform = "cpu-d3" + cpu_nodes_preset = "16vcpu-64gb" + } + eu-north1 = { + cpu_nodes_platform = "cpu-e2" + cpu_nodes_preset = "16vcpu-64gb" + } + } + + current_region_defaults = local.regions_default[var.region] + + cpu_nodes_preset = coalesce(var.cpu_nodes_preset, local.current_region_defaults.cpu_nodes_preset) + cpu_nodes_platform = coalesce(var.cpu_nodes_platform, local.current_region_defaults.cpu_nodes_platform) } diff --git a/nfs-server/main.tf b/nfs-server/main.tf index 10d495ac..39085d14 100644 --- a/nfs-server/main.tf +++ b/nfs-server/main.tf @@ -9,4 +9,6 @@ module "nfs-module" { ssh_public_key = var.ssh_public_key.key nfs_ip_range = var.nfs_ip_range nfs_size = var.nfs_size + platform = local.cpu_nodes_platform + preset = local.cpu_nodes_preset } diff --git a/nfs-server/nfs.tfvars b/nfs-server/terraform.tfvars similarity index 88% rename from nfs-server/nfs.tfvars rename to nfs-server/terraform.tfvars index 275cf081..d1f874e1 100644 --- a/nfs-server/nfs.tfvars +++ b/nfs-server/terraform.tfvars @@ -1,5 +1,6 @@ parent_id = "project-..." subnet_id = "vpcsubnet-..." +region = "eu-north1" ssh_user_name = "nfs" ssh_public_key = { key = "put your ssh key here" diff --git a/nfs-server/variables.tf b/nfs-server/variables.tf index 369cefba..d04c7ed3 100644 --- a/nfs-server/variables.tf +++ b/nfs-server/variables.tf @@ -8,6 +8,23 @@ variable "subnet_id" { description = "ID of the subnet." } +variable "region" { + type = string + description = "Project region." +} + +variable "cpu_nodes_platform" { + description = "Platform for instances." + type = string + default = null +} + +variable "cpu_nodes_preset" { + description = "CPU and RAM configuration for instances." + type = string + default = null +} + variable "nfs_size" { type = number default = 93 * 1024 * 1024 * 1024 # size should be a multiple of 99857989632