Skip to content

[Bug]: Cannot assign a private server to a subnet without other IP/Interface assigned #1265

@mlinares1998

Description

@mlinares1998

What happened?

Hi Team,
I've encountered an issue when trying to use the new subnet assignment feature from v1.56.0 (#1217).

When creating a VM without a network block or public IP enabled (expecting hcloud_server_network to handle the subnet assignment), the hcloud_server resource fails. The creation fails as the instance cannot start because it has no interface assigned at creation time.

The VM should be created and then have its network/subnet assigned via hcloud_server_network.

Has anyone else encountered this?
Regards!

Log:

 Error: hcloudutil/WaitForAction: no public or private network interfaces found, cannot start server (invalid_input, 593478587344330)
  │ 
  │   with hcloud_server.test,
  │   on test_vm.tf line 1, in resource "hcloud_server" "test":
  │    1: resource "hcloud_server" "test" {
  │ 

What did you expect to happen?

The VM should be created and then have its network/subnet assigned via hcloud_server_network.

Please provide a minimal working example

Problematic code

resource "hcloud_server" "test" {
  depends_on = [hcloud_network_subnet.subnet]

  name                     = "debian-test-fsn1-staging"
  server_type              = "cax11"
  datacenter               = "fsn1-dc14"
  image                    = "debian-13"
  keep_disk                = true
  backups                  = false
  labels                   = merge(var.labels, {})
  shutdown_before_deletion = true

  ssh_keys = [hcloud_ssh_key.env.id]

  public_net {
    ipv4_enabled = false
    ipv6_enabled = false
  }

  user_data = <<EOF
#cloud-config
write_files:
  - path: /etc/network/interfaces
    content: |
      auto enp7s0
      iface enp7s0 inet dhcp
          post-up echo "Waiting..."
          post-up ip route add default via 10.11.0.1
          dns-nameservers ${var.nat_ip}
    append: true
runcmd:
  - reboot
EOF
}

resource "hcloud_server_network" "node1_subnet1" {
  server_id = hcloud_server.test.id
  subnet_id = "11180245-10.11.95.0/25"
  alias_ips = []
}

Enabling public IP fixes the problem.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions