|
| 1 | +variable "clusters" { |
| 2 | + type = map(object({ |
| 3 | + kubernetes_version_min = optional(string) |
| 4 | + region = optional(string) |
| 5 | + |
| 6 | + node_pools = list(object({ |
| 7 | + name = string |
| 8 | + machine_type = optional(string, "c1.2") |
| 9 | + minimum = optional(number, 1) |
| 10 | + maximum = optional(number, 2) |
| 11 | + availability_zones = optional(list(string), ["eu01-m"]) # max two eu01-1, eu01-2, eu01-3, eu01-m |
| 12 | + allow_system_components = optional(bool, false) |
| 13 | + cri = optional(string, "containerd") |
| 14 | + labels = optional(map(string)) |
| 15 | + max_surge = optional(number, 2) |
| 16 | + max_unavailable = optional(number) |
| 17 | + os_name = optional(string, "flatcar") # or "ubuntu" |
| 18 | + os_version_min = optional(string) |
| 19 | + volume_size = optional(number, 20) |
| 20 | + volume_type = optional(string, "storage_premium_perf1") |
| 21 | + taints = optional(list(object({ |
| 22 | + effect = string |
| 23 | + key = string |
| 24 | + value = optional(string) |
| 25 | + }))) |
| 26 | + })) |
| 27 | + |
| 28 | + maintenance = optional(object({ |
| 29 | + enable_kubernetes_version_updates = optional(bool, true) |
| 30 | + enable_machine_image_version_updates = optional(bool, true) |
| 31 | + start = string |
| 32 | + end = string |
| 33 | + }), { |
| 34 | + enable_kubernetes_version_updates = true |
| 35 | + enable_machine_image_version_updates = true |
| 36 | + start = "01:00:00Z" |
| 37 | + end = "02:00:00Z" |
| 38 | + }) |
| 39 | + |
| 40 | + network_id = optional(string) |
| 41 | + public_access_enabled = optional(bool, true) |
| 42 | + |
| 43 | + extensions = optional(object({ |
| 44 | + acl = optional(object({ |
| 45 | + enabled = bool |
| 46 | + allowed_cidrs = list(string) |
| 47 | + })) |
| 48 | + dns = optional(object({ |
| 49 | + enabled = bool |
| 50 | + zones = optional(list(string)) |
| 51 | + })) |
| 52 | + observability = optional(object({ |
| 53 | + enabled = bool |
| 54 | + instance_id = optional(string) |
| 55 | + })) |
| 56 | + })) |
| 57 | + |
| 58 | + hibernations = optional(list(object({ |
| 59 | + start = string |
| 60 | + end = string |
| 61 | + timezone = optional(string) |
| 62 | + }))) |
| 63 | + })) |
| 64 | + description = "Map of SKE cluster configurations. The map key is used as the cluster name." |
| 65 | + |
| 66 | + validation { |
| 67 | + condition = alltrue([ |
| 68 | + for name, _ in var.clusters : |
| 69 | + can(regex("^[a-z][a-z0-9-]*$", name)) |
| 70 | + ]) |
| 71 | + error_message = "Cluster names must start with a lowercase letter and contain only lowercase letters, numbers, and hyphens." |
| 72 | + } |
| 73 | + |
| 74 | + validation { |
| 75 | + condition = alltrue(flatten([ |
| 76 | + for cluster in var.clusters : [ |
| 77 | + for np in cluster.node_pools : |
| 78 | + np.minimum >= 1 |
| 79 | + ] |
| 80 | + ])) |
| 81 | + error_message = "Node pool minimum must be at least 1." |
| 82 | + } |
| 83 | + |
| 84 | + validation { |
| 85 | + condition = alltrue(flatten([ |
| 86 | + for cluster in var.clusters : [ |
| 87 | + for np in cluster.node_pools : |
| 88 | + np.minimum <= np.maximum |
| 89 | + ] |
| 90 | + ])) |
| 91 | + error_message = "Node pool minimum must be less than or equal to maximum." |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | +variable "project_id" { |
| 96 | + type = string |
| 97 | + description = "STACKIT project ID to which the clusters are associated." |
| 98 | + |
| 99 | + validation { |
| 100 | + condition = can(regex("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$", var.project_id)) |
| 101 | + error_message = "The project_id must be a valid UUID." |
| 102 | + } |
| 103 | +} |
0 commit comments