Provider Crashs when NIC IPs is a list with an emtpy string
mueller-tobias opened this issue · 2 comments
mueller-tobias commented
Description
When i create a vm with a NIC, the provider will crash when the user only supply an list with an empty string.
The resource will be created when:
- local.vm_ip is a ip_address
- null
But the provider will crash if the user provides only an emtpy string for example aka
locals {
vm_ip = ""
}
Expected behavior
When IPs is a List with an empty the string, the VM should be created without a specified ip or the provider should throw an error in the terraform plan
phase.
Environment
Terraform version:
1.3.9
Provider version:
v6.3.5
OS:
MacOS Ventura 13.2.1
Configuration Files
How to Reproduce
locals {
vm_ip = ""
}
resource "ionoscloud_server" "virtual_machine" {
name = var.name
datacenter_id = var.datacenter_id
cores = var.cpu_cores
ram = var.memory
availability_zone = "AUTO"
cpu_family = var.cpu_family
image_name = data.ionoscloud_image.image.id
image_password = random_password.server_image_password.result
type = "ENTERPRISE"
volume {
name = "${var.name}_volume"
size = 15
disk_type = "SSD Standard"
user_data = data.cloudinit_config.virtual_machine.rendered
bus = "VIRTIO"
availability_zone = "AUTO"
}
nic {
lan = var.network_id
name = "${var.name}_nic"
dhcp = true
firewall_active = false
ips = [local.vm_ip]
}
label {
key = "labelkey1"
value = "labelvalue1"
}
label {
key = "labelkey2"
value = "labelvalue2"
}
lifecycle {
ignore_changes = [volume[0].user_data]
}
}
Error and Debug Output
Stack trace from the terraform-provider-ionoscloud_v6.3.5 plugin:
panic: interface conversion: interface {} is nil, not string
goroutine 57 [running]:
github.com/ionos-cloud/terraform-provider-ionoscloud/v6/ionoscloud.getNicData(0x1400014a250?, {0x102cb14f3, 0x6})
github.com/ionos-cloud/terraform-provider-ionoscloud/v6/ionoscloud/resource_nic.go:245 +0x5c4
github.com/ionos-cloud/terraform-provider-ionoscloud/v6/ionoscloud.resourceServerCreate({0x103099fa8, 0x1400051cc60}, 0x140000d0b00, {0x1030005a0?, 0x140004a33e0?})
github.com/ionos-cloud/terraform-provider-ionoscloud/v6/ionoscloud/resource_server.go:523 +0x758
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x14000299180, {0x103099fe0, 0x14000218a80}, 0xd?, {0x1030005a0, 0x140004a33e0})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.22.0/helper/schema/resource.go:707 +0xec
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0x14000299180, {0x103099fe0, 0x14000218a80}, 0x14000227930, 0x140000d0480, {0x1030005a0, 0x140004a33e0})
github.com/hashicorp/terraform-plugin-sdk/v2@v2.22.0/helper/schema/resource.go:837 +0x874
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0x14000285b48, {0x103099fe0?, 0x14000218570?}, 0x14000426d70)
github.com/hashicorp/terraform-plugin-sdk/v2@v2.22.0/helper/schema/grpc_provider.go:1021 +0xb94
github.com/hashicorp/terraform-plugin-go/tfprotov5/tf5server.(*server).ApplyResourceChange(0x140003e9e00, {0x103099fe0?, 0x14000411590?}, 0x140000cfdc0)
github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/tf5server/server.go:818 +0x3c0
github.com/hashicorp/terraform-plugin-go/tfprotov5/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x103033000?, 0x140003e9e00}, {0x103099fe0, 0x14000411590}, 0x140000cfd50, 0x0)
github.com/hashicorp/terraform-plugin-go@v0.14.0/tfprotov5/internal/tfplugin5/tfplugin5_grpc.pb.go:385 +0x174
google.golang.org/grpc.(*Server).processUnaryRPC(0x14000432000, {0x10309cbe0, 0x140004c6d00}, 0x140002218c0, 0x140004a2ba0, 0x10374fec0, 0x0)
google.golang.org/grpc@v1.48.0/server.go:1295 +0x9d8
google.golang.org/grpc.(*Server).handleStream(0x14000432000, {0x10309cbe0, 0x140004c6d00}, 0x140002218c0, 0x0)
google.golang.org/grpc@v1.48.0/server.go:1636 +0x840
google.golang.org/grpc.(*Server).serveStreams.func1.2()
google.golang.org/grpc@v1.48.0/server.go:932 +0x88
created by google.golang.org/grpc.(*Server).serveStreams.func1
google.golang.org/grpc@v1.48.0/server.go:930 +0x298
Error: The terraform-provider-ionoscloud_v6.3.5 plugin crashed!
gabi-ionos commented
Hello, the fix will be available with the next terraform version which will be 6.3.6
cristiGuranIonos commented
Fixed in v6.3.6