Skip to content

Commit

Permalink
Added "region" variable to control platform defaults (NFS Server);
Browse files Browse the repository at this point in the history
  • Loading branch information
elijah-k-nebius committed Nov 21, 2024
1 parent ab7b2de commit 5216c7a
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions nfs-server/locals.tf
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 2 additions & 0 deletions nfs-server/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
1 change: 1 addition & 0 deletions nfs-server/nfs.tfvars → nfs-server/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
17 changes: 17 additions & 0 deletions nfs-server/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5216c7a

Please sign in to comment.