terraform-provider-hcloud icon indicating copy to clipboard operation
terraform-provider-hcloud copied to clipboard

Create loadbalancer with count.

Open spyrosamvra opened this issue 2 years ago • 1 comments

╷ │ Error: Provider produced inconsistent result after apply │ │ When applying changes to hcloud_load_balancer_target.load_balancer_target[0], provider "provider["registry.terraform.io/hetznercloud/hcloud"]" produced an
│ unexpected new value: Root resource was present, but now absent. │ │ This is a bug in the provider, which should be reported in the provider's own issue tracker. ╵ ╷ │ Error: Provider produced inconsistent result after apply │ │ When applying changes to hcloud_load_balancer_target.load_balancer_target[1], provider "provider["registry.terraform.io/hetznercloud/hcloud"]" produced an
│ unexpected new value: Root resource was present, but now absent. │ │ This is a bug in the provider, which should be reported in the provider's own issue tracker.

spyrosamvra avatar Jun 23 '22 15:06 spyrosamvra

Here is all the files i wrote to repeat the error : https://github.com/spyrosamvra/terraform.git I delete my htoken so you only need to add yours in var.provider.tf

spyrosamvra avatar Jun 23 '22 15:06 spyrosamvra

Hi @spyrosamvra,

thanks for reporting the bug. I created a PR to fix the issues: #596.

These issues showed up for you, because you used a datacenter.id for the loadbalancer location. The correct argument would have been a location.name. I created another PR to improve the docs for this: #595

You can make these changes to your files to fix it:

+data "hcloud_location" "location" {
+  name = "hel1"
+}

 resource "hcloud_load_balancer" "loadbalancers" {
   count              = length(local.lb_names)
   name               = local.lb_names[count.index]
   load_balancer_type = var.lb_type
-  location           = data.hcloud_datacenter.datacenter.id
+  location           = data.hcloud_location.location.name
 }

apricote avatar Nov 23 '22 13:11 apricote

PR #596 is merged! Thanks again for reporting.

apricote avatar Nov 29 '22 10:11 apricote