upcloud: v5.6.0 and better server groups (#11311)

pull/11258/head
Robin Wallace 2024-06-26 10:42:21 +02:00 committed by GitHub
parent c352773737
commit 15b62cc7ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 36 additions and 16 deletions

View File

@ -56,9 +56,10 @@ resource "upcloud_server" "master" {
hostname = "${local.resource-prefix}${each.key}"
plan = each.value.plan
cpu = each.value.plan == null ? each.value.cpu : null
mem = each.value.plan == null ? each.value.mem : null
cpu = each.value.plan == null ? null : each.value.cpu
mem = each.value.plan == null ? null : each.value.mem
zone = var.zone
server_group = each.value.server_group == null ? null : upcloud_server_group.server_groups[each.value.server_group].id
template {
storage = var.template_name
@ -113,9 +114,11 @@ resource "upcloud_server" "worker" {
hostname = "${local.resource-prefix}${each.key}"
plan = each.value.plan
cpu = each.value.plan == null ? each.value.cpu : null
mem = each.value.plan == null ? each.value.mem : null
cpu = each.value.plan == null ? null : each.value.cpu
mem = each.value.plan == null ? null : each.value.mem
zone = var.zone
server_group = each.value.server_group == null ? null : upcloud_server_group.server_groups[each.value.server_group].id
template {
storage = var.template_name
@ -513,7 +516,17 @@ resource "upcloud_loadbalancer" "lb" {
name = "${local.resource-prefix}lb"
plan = var.loadbalancer_plan
zone = var.zone
networks {
name = "Private-Net"
type = "private"
family = "IPv4"
network = upcloud_network.private.id
}
networks {
name = "Public-Net"
type = "public"
family = "IPv4"
}
}
resource "upcloud_loadbalancer_backend" "lb_backend" {
@ -534,6 +547,9 @@ resource "upcloud_loadbalancer_frontend" "lb_frontend" {
mode = "tcp"
port = each.value.port
default_backend_name = upcloud_loadbalancer_backend.lb_backend[each.key].name
networks {
name = "Public-Net"
}
}
resource "upcloud_loadbalancer_static_backend_member" "lb_backend_member" {
@ -557,5 +573,9 @@ resource "upcloud_server_group" "server_groups" {
title = each.key
anti_affinity_policy = each.value.anti_affinity_policy
labels = {}
members = [for server in each.value.servers : merge(upcloud_server.master, upcloud_server.worker)[server].id]
# Managed upstream via upcloud_server resource
members = []
lifecycle {
ignore_changes = [members]
}
}

View File

@ -20,6 +20,7 @@ variable "machines" {
cpu = string
mem = string
disk_size = number
server_group : string
additional_disks = map(object({
size = number
tier = string
@ -104,6 +105,5 @@ variable "server_groups" {
type = map(object({
anti_affinity_policy = string
servers = list(string)
}))
}

View File

@ -3,7 +3,7 @@ terraform {
required_providers {
upcloud = {
source = "UpCloudLtd/upcloud"
version = "~>2.12.0"
version = "~>5.6.0"
}
}
required_version = ">= 0.13"

View File

@ -32,6 +32,7 @@ variable "machines" {
cpu = string
mem = string
disk_size = number
server_group : string
additional_disks = map(object({
size = number
tier = string
@ -142,7 +143,6 @@ variable "server_groups" {
type = map(object({
anti_affinity_policy = string
servers = list(string)
}))
default = {}

View File

@ -3,7 +3,7 @@ terraform {
required_providers {
upcloud = {
source = "UpCloudLtd/upcloud"
version = "~>2.12.0"
version = "~>5.6.0"
}
}
required_version = ">= 0.13"