hetznercloud / terraform-provider-hcloud

Terraform Hetzner Cloud provider
https://registry.terraform.io/providers/hetznercloud/hcloud/latest
Mozilla Public License 2.0
491 stars 71 forks source link

[Bug]: Changing hcloud server from arm64 to x86 results in an error #853

Open mzhaase opened 7 months ago

mzhaase commented 7 months ago

What happened?

Changed the type of a server from an ARM one to an x86 one. Terraform output:

 # module.kubernetes-cluster.hcloud_server.worker[1] will be updated in-place
resource "hcloud_server" "worker" {
       ...
      ~ server_type                = "cax11" -> "cx11"
...
    }

 Error: server type has incompatible architecture (invalid_server_type)

What did you expect to happen?

When changing the server so architectures are switched, the server should probably be recreated instead of updated-in-place.

Please provide a minimal working example

resource "hcloud_server" "worker" {
    image         = "debian12
    location      = "fsn1"
    name          = "worker"
    server_type = "cax11"
    ssh_key       = xxx
}

Deploy, then change "cax11" to "cx11"

apricote commented 7 months ago

Hey @mzhaase,

thanks for the report!

Unfortunately this is not possible with the current code. With the Terraform Provider SDKv2, which we currently use to implement most of the resources, we can only mark a field as always or never forcing a replacement. As changing the server type within an architecture is supported, we would like to keep this as is.

We are currently migrating to the new Terraform Provider Plugin Framework (#752), which supports conditionally forcing a replacement. The hcloud_server resource is planned as one of the next resources to refactor, as we already know of a few bugs that we can finally solve with the new Plugin Framework.

For now, you can manually tell terraform to replace the resource through terraform apply -replace="hcloud_server.worker" or by tainting the resource and then applying: terraform taint hcloud_server.worker.