terraform-hcloud-k3s
terraform-hcloud-k3s copied to clipboard
[Bug]: Node Pool validation disallows some server types
What happened?
Once again – big, big thanks for building this! 💚
I'm playing around with it, and just noticed that my account allows a new server type (CX22) which the node pool validation rejects. You have a regex there, so I don't dare offer a PR for it.
# file://.terraform/modules/cluster/node_pool/pool.tf:215-222
variable "node_type" {
description = "Node type (size)."
type = string
validation {
condition = can(regex("^(cp?x[1-5]1|cax[1-4]1|ccx[1-6]3)$", var.node_type))
error_message = "Node type is not valid."
}
}
Here's proof that I have this type:
I apologize in advance if [Bug] is a miscategorization of the issue.
What did you expect to happen?
To support CX22, I believe the snippet should be changed to:
# file://.terraform/modules/cluster/node_pool/pool.tf:215-222
variable "node_type" {
description = "Node type (size)."
type = string
validation {
condition = can(regex("^(cp?x[1-5][12]|cax[1-4]1|ccx[1-6]3)$", var.node_type))
error_message = "Node type is not valid."
}
}
I will now manually force-bypass the validation rule to get my config to work, but I think there's benefit from making a change in the original module.
Further optimization
I'm thinking a step further now… is this the best way to continue? As Hetzner changes their server pool, you will need to update this regex (and will likely have such issues forever). Maybe I can offer some thoughts on this – it feels like it's best to just pull the list of allowed node types dynamically from the API, based on the selected region… the readonly API key should already be there if we're at the stage of running tf plan or tf apply, and we can anyway request a monthly estimate as output to additionally validate this selection.
I hope this is helpful, and wish you best of luck with this project!
Please provide a minimal working example
I believe it's provided in the examples and suggestions above. Initially opened here.