TGNThump / terraform-provider-vyos

Terraform Provider for VyOS
https://registry.terraform.io/providers/TGNThump/vyos
Mozilla Public License 2.0
11 stars 4 forks source link

Error: Configuration path 'interfaces ethernet eth0' already exists, try a resource import instead. #51

Open HOZAMA opened 5 months ago

HOZAMA commented 5 months ago

I use Terraform to create a virtual machine from a VyOS image using cloud-init for initial setup of the eth0 interface.

Then I continue configuring this virtual machine using your provider. One of the tasks is to modify the settings of this interface (add a description) and create a virtual interface.

resource "vyos_config" "interface-servers" { count = var.config.zones.servers.count path = "interfaces ethernet ${var.config.zones.servers.interface}" value = jsonencode({ "description" = "SERVERS" }) lifecycle { create_before_destroy = true } }

resource "vyos_config" "interface-lan" { count = var.config.zones.lan.count

path = "interfaces ethernet ${var.config.zones.lan.interface}" value = jsonencode({ "vif" = { "100" = { "description" = "LAN" "address" = "${cidrhost(var.networks.lan, 1)}/30" } } }) lifecycle { create_before_destroy = true } }

However, an error occurs because this resource already exists. How can this problem be resolved?

JonnyHaystack commented 1 month ago

Use an import block (as the error message will suggest to you)