diff --git a/contrib/terraform/upcloud/cluster-settings.tfvars b/contrib/terraform/upcloud/cluster-settings.tfvars index eae1551e221d6c7fdbc1714b97c19cb679fbd849..7e1296fd3a9f632b6cc018a77c0819c34b0558f3 100644 --- a/contrib/terraform/upcloud/cluster-settings.tfvars +++ b/contrib/terraform/upcloud/cluster-settings.tfvars @@ -1,5 +1,11 @@ # See: https://developers.upcloud.com/1.3/5-zones/ -zone = "fi-hel1" +zone = "fi-hel1" +private_cloud = false + +# Only used if private_cloud = true, public zone equivalent +# For example use finnish public zone for finnish private zone +public_zone = "fi-hel2" + username = "ubuntu" # Prefix to use for all resources to separate them from other resources diff --git a/contrib/terraform/upcloud/main.tf b/contrib/terraform/upcloud/main.tf index 30986667dd5fdb1c0df0540b77bc4f83516ce8b6..78fc0786fb63a69f24b3785f9c233f2dcd1b325f 100644 --- a/contrib/terraform/upcloud/main.tf +++ b/contrib/terraform/upcloud/main.tf @@ -11,8 +11,10 @@ provider "upcloud" { module "kubernetes" { source = "./modules/kubernetes-cluster" - prefix = var.prefix - zone = var.zone + prefix = var.prefix + zone = var.zone + private_cloud = var.private_cloud + public_zone = var.public_zone template_name = var.template_name username = var.username diff --git a/contrib/terraform/upcloud/modules/kubernetes-cluster/main.tf b/contrib/terraform/upcloud/modules/kubernetes-cluster/main.tf index 54743a9e7f6b418593cbc1dddb1baee7af175d6d..91c8b9ec7b32e0dd2773f70a9b97a673a6099401 100644 --- a/contrib/terraform/upcloud/modules/kubernetes-cluster/main.tf +++ b/contrib/terraform/upcloud/modules/kubernetes-cluster/main.tf @@ -515,7 +515,7 @@ resource "upcloud_loadbalancer" "lb" { configured_status = "started" name = "${local.resource-prefix}lb" plan = var.loadbalancer_plan - zone = var.zone + zone = var.private_cloud ? var.public_zone : var.zone networks { name = "Private-Net" type = "private" diff --git a/contrib/terraform/upcloud/modules/kubernetes-cluster/variables.tf b/contrib/terraform/upcloud/modules/kubernetes-cluster/variables.tf index 530409f09c536d0e6e4ace1f8ce70e2e5c9e6116..4c41cc08f1a089dc730e63f1f3426e4f36bddb68 100644 --- a/contrib/terraform/upcloud/modules/kubernetes-cluster/variables.tf +++ b/contrib/terraform/upcloud/modules/kubernetes-cluster/variables.tf @@ -6,6 +6,14 @@ variable "zone" { type = string } +variable "private_cloud" { + type = bool +} + +variable "public_zone" { + type = string +} + variable "template_name" {} variable "username" {} diff --git a/contrib/terraform/upcloud/variables.tf b/contrib/terraform/upcloud/variables.tf index 58c626ab9ac49d4d5fada03ef2ba23509f70d206..0ea81b99a4e0e2c6c6dc2d093b602b6edc1c98e5 100644 --- a/contrib/terraform/upcloud/variables.tf +++ b/contrib/terraform/upcloud/variables.tf @@ -9,6 +9,15 @@ variable "zone" { description = "The zone where to run the cluster" } +variable "private_cloud" { + description = "Whether the environment is in the private cloud region" + default = false +} + +variable "public_zone" { + description = "The public zone equivalent if the cluster is running in a private cloud zone" +} + variable "template_name" { description = "Block describing the preconfigured operating system" }