[Bug]: Assigning public IPv4 to an existing server breaks reverse DNS entry
cebe opened this issue · comments
Carsten Brandt commented
What happened?
# terraform apply
[...]
# hcloud_rdns.cloud_ftp_ipv4[0] will be created
+ resource "hcloud_rdns" "cloud_ftp_ipv4" {
+ dns_ptr = "ftp1.ftp.cloud2.[..]"
+ id = (known after apply)
+ server_id = 48738290
# (1 unchanged attribute hidden)
}
# hcloud_rdns.cloud_ftp_ipv6[0] will be created
+ resource "hcloud_rdns" "cloud_ftp_ipv6" {
+ dns_ptr = "ftp1.ftp.cloud2.[..]"
+ id = (known after apply)
+ ip_address = "2a01:4f8:[..]"
+ server_id = 48738290
}
# hcloud_server.cloud_ftp[0] will be updated in-place
~ resource "hcloud_server" "cloud_ftp" {
id = "48738290"
name = "ftp1.ftp.cloud2.[..]"
# (22 unchanged attributes hidden)
- public_net {
- ipv4 = 0 -> null
- ipv4_enabled = false -> null
- ipv6 = 0 -> null
- ipv6_enabled = true -> null
}
+ public_net {
+ ipv4 = (known after apply)
+ ipv4_enabled = true
+ ipv6 = (known after apply)
+ ipv6_enabled = true
}
# (1 unchanged block hidden)
}
[...]
Plan: 3 to add, 3 to change, 1 to destroy.
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
[...]
hcloud_server.cloud_ftp[0]: Modifying... [id=48738290]
hcloud_server.cloud_ftp[0]: Still modifying... [id=48738290, 10s elapsed]
hcloud_server.cloud_ftp[0]: Modifications complete after 16s [id=48738290]
hcloud_rdns.cloud_ftp_ipv6[0]: Creating...
hcloud_rdns.cloud_ftp_ipv6[0]: Creation complete after 2s [id=s-48738290-2a01:4f8:c17:62bf::1]
╷
│ Error: Provider produced inconsistent final plan
│
│ When expanding the plan for hcloud_rdns.cloud_ftp_ipv4[0] to include new values learned so far during apply, provider "registry.terraform.io/hetznercloud/hcloud" produced an invalid new value for .ip_address: was cty.StringVal(""), but now cty.StringVal("157.90.248.65").
│
│ This is a bug in the provider, which should be reported in the provider's own issue tracker.
╵
What did you expect to happen?
I expect the new IPv4 added and the reverse DNS entry to be updated without error.
Please provide a minimal working example
terraform {
required_providers {
hcloud = {
source = "hetznercloud/hcloud"
version = "1.47.0"
}
}
required_version = ">= 1.0.0"
}
provider "hcloud" {
token = "Neo8FwsD6w2aEM1...N9U"
}
# use SSH key from home dir
resource "hcloud_ssh_key" "instance-ssh-key" {
name = "instance-ssh-key"
public_key = file("~/.ssh/id_rsa.pub")
}
resource "hcloud_server" "cloud_ftp" {
count = 1
name = "ftp${count.index + 1}.ftp.example.com"
image = "debian-12"
server_type = "cax21"
location = "hel1"
ssh_keys = [hcloud_ssh_key.instance-ssh-key.id]
# in case of upgrade, keep disk size to allow downgrade later
keep_disk = true
public_net {
ipv4_enabled = false
# ipv4_enabled = true
ipv6_enabled = true
}
depends_on = [
hcloud_ssh_key.instance-ssh-key
]
}
resource "hcloud_rdns" "cloud_ftp_ipv6" {
count = 1
# for = toset(range(0, var.k8s_cluster_nodes - 1))
server_id = hcloud_server.cloud_ftp[count.index].id
ip_address = hcloud_server.cloud_ftp[count.index].ipv6_address
dns_ptr = hcloud_server.cloud_ftp[count.index].name
}
#resource "hcloud_rdns" "cloud_ftp_ipv4" {
# count = 1
# # for = toset(range(0, var.k8s_cluster_nodes - 1))
# server_id = hcloud_server.cloud_ftp[count.index].id
# ip_address = hcloud_server.cloud_ftp[count.index].ipv4_address
# dns_ptr = hcloud_server.cloud_ftp[count.index].name
#}
steps to reproduce:
- create file with the content above in an empty directory, enter your hetzner cloud api key
terraform init
terraform apply
- set
ipv4_enabled = true
in servers public_net - uncomment resource "hcloud_rdns"
terraform apply
Carsten Brandt commented
Workaround: Running terraform apply
again, makes the correct changes.