What happened?
ipv4 addr get deleted (note: no deletion is shown via tofo plan) and this will result in an error msg (1) (see below). this are the steps i took:
- create primary-ip resource (ipv4 and ipv4)
- create server resource with resource from step 1.
- import server resource (result in deleted ipv4 addr.)
after step 3. hcloud primary-ip list shows that the ipv4 is deleted, while the ipv6 addr works as expected. (also tested with delete-protection == true. this will fail with an error msg (2) on the first run, while a second run will recover from that err. due to the delete-protection the ipv4 will not be deleted. but this is clearly not the intended behavior.)
err msg 1
2026-04-12T23:29:00.464+0200 [ERROR] provider.terraform-provider-hcloud_v1.60.1: Response contains error diagnostic: @module=sdk.proto tf_req_id=72c54ae1-bda9-08bb-6b7f-bf2c59d415ce tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-go@v0.29.0/tfprotov6/internal/diag/diagnostics.go:58 diagnostic_detail="" diagnostic_severity=ERROR diagnostic_summary="Primary IP with ID 126355586 not found (not_found, 409c8d7a6f94da1ef81e891dff29927b)" tf_proto_version=6.10 tf_provider_addr=registry.terraform.io/hetznercloud/hcloud tf_resource_type=hcloud_server timestamp="2026-04-12T23:29:00.464+0200"
2026-04-12T23:29:00.467+0200 [ERROR] vertex "hcloud_server.main" error: Primary IP with ID 126355586 not found (not_found, 409c8d7a6f94da1ef81e891dff29927b)
Error: Primary IP with ID 126355586 not found (not_found, 409c8d7a6f94da1ef81e891dff29927b)
with hcloud_server.main,
on server.tf line 20, in resource "hcloud_server" "main":
20: resource "hcloud_server" "main" {
err msg 2
2026-04-12T23:00:42.255+0200 [ERROR] provider.terraform-provider-hcloud_v1.60.1: Response contains error diagnostic: tf_rpc=ApplyResourceChange @module=sdk.proto diagnostic_d
etail="" diagnostic_severity=ERROR diagnostic_summary="Primary IP deletion is protected (protected, fd8fafe3e6cadeefddd99a08968e0ef9)" tf_proto_version=6.10 tf_req_id=ac0c99b
7-e122-e748-86ef-752166a23e8f @caller=github.com/hashicorp/terraform-plugin-go@v0.29.0/tfprotov6/internal/diag/diagnostics.go:58 tf_provider_addr=registry.terraform.io/hetzne
rcloud/hcloud tf_resource_type=hcloud_server timestamp="2026-04-12T23:00:42.255+0200"
2026-04-12T23:00:42.258+0200 [ERROR] vertex "hcloud_server.main" error: Primary IP deletion is protected (protected, fd8fafe3e6cadeefddd99a08968e0ef9)
Error: Primary IP deletion is protected (protected, fd8fafe3e6cadeefddd99a08968e0ef9)
with hcloud_server.main,
on server.tf line 20, in resource "hcloud_server" "main":
20: resource "hcloud_server" "main" {
What did you expect to happen?
an import server resource should not delete ipv4 addr. (the ipv4 addr resource is managed in an extra state file and thus i expected it will not be altered.)
Please provide a minimal working example
primary-ip resource
resource "hcloud_primary_ip" "ipv4" {
name = "test-ipv4"
type = "ipv4"
location = "fsn1"
assignee_type = "server"
auto_delete = false
delete_protection = false
}
resource "hcloud_primary_ip" "ipv6" {
name = "test-ipv6"
type = "ipv6"
location = "fsn1"
assignee_type = "server"
auto_delete = false
delete_protection = false
}
server resource
data "hcloud_primary_ip" "ipv4" {
name = "test-ipv4"
}
data "hcloud_primary_ip" "ipv6" {
name = "test-ipv6"
}
resource "hcloud_server" "main" {
name = "test"
image = "debian-13"
server_type = "cx23"
location = "fsn1"
keep_disk = true
backups = false
ssh_keys = [XXXXXXXX]
public_net {
ipv4_enabled = true
ipv4 = data.hcloud_primary_ip.ipv4.id
ipv6_enabled = true
ipv6 = data.hcloud_primary_ip.ipv6.id
}
}
server import
data "hcloud_primary_ip" "ipv4" {
name = "test-ipv4"
}
data "hcloud_primary_ip" "ipv6" {
name = "test-ipv6"
}
data "hcloud_server" "main" {
name = "test"
}
import {
to = hcloud_server.main
id = data.hcloud_server.main.id
}
resource "hcloud_server" "main" {
name = "test"
server_type = "cx23"
image = "debian-13"
ssh_keys = [XXXXXXXX]
public_net {
ipv4_enabled = true
ipv4 = data.hcloud_primary_ip.ipv4.id
ipv6_enabled = true
ipv6 = data.hcloud_primary_ip.ipv6.id
}
# prevent destroy and recreate of server resource on import
lifecycle {
ignore_changes = [
image, ssh_keys
]
}
}
version
version = "~> 1.60"
What happened?
ipv4 addr get deleted (note: no deletion is shown via
tofo plan) and this will result in an error msg (1) (see below). this are the steps i took:after step 3.
hcloud primary-ip listshows that the ipv4 is deleted, while the ipv6 addr works as expected. (also tested with delete-protection == true. this will fail with an error msg (2) on the first run, while a second run will recover from that err. due to thedelete-protectionthe ipv4 will not be deleted. but this is clearly not the intended behavior.)err msg 1
err msg 2
What did you expect to happen?
an import server resource should not delete ipv4 addr. (the ipv4 addr resource is managed in an extra state file and thus i expected it will not be altered.)
Please provide a minimal working example
primary-ip resource
server resource
server import
version
version = "~> 1.60"