PaloAltoNetworks / terraform-provider-panos

Terraform Panos provider
https://www.terraform.io/docs/providers/panos/
MIT License
89 stars 73 forks source link

Provider plugin crashes when trying to add a static route to virtual router #394

Closed gvoden closed 1 year ago

gvoden commented 1 year ago

Describe the bug

I am trying to add a static route to an already created virtual router. Terraform apply fails saying provider plugin crashed.

Expected behavior

A static route should be created by terraform apply

Current behavior

Terraform apply fails

Possible solution

I am using the latest version 1.11.1. Should I downgrade to a lower version of the plugin.

Steps to reproduce

module.panorama.panos_static_route_ipv4.this["vr1.route1"]: Creating... ╷ │ Error: Plugin did not respond │ │ with module.panorama.panos_static_route_ipv4.this["vr1.route1"], │ on .terraform\modules\panorama\virtual_router.tf line 30, in resource "panos_static_route_ipv4" "this": │ 30: resource "panos_static_route_ipv4" "this" { │ │ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details. ╵ Releasing state lock. This may take a few moments...

Stack trace from the terraform-provider-panos_v1.11.1.exe plugin:

panic: interface conversion: interface {} is pango.Panorama, not pango.Firewall

goroutine 28 [running]: github.com/terraform-providers/terraform-provider-panos/panos.createStaticRouteIpv4(0x1c2c2e0, {0x1da2680, 0xc0000021e0}) github.com/terraform-providers/terraform-provider-panos/panos/resource_static_route_ipv4.go:103 +0x28f github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Resource).Apply(0xc0007465a0, 0xc0003392c0, 0xc000c55a60, {0x1da2680, 0xc0000021e0}) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/resource.go:320 +0x438 github.com/hashicorp/terraform-plugin-sdk/helper/schema.(Provider).Apply(0xc000098500, 0xc0000e3a68, 0x1db6964, 0xf) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/helper/schema/provider.go:294 +0x70 github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(GRPCProviderServer).ApplyResourceChange(0xc000006af0, {0xc000c7a2a0, 0xf48de6}, 0xc000c7a2a0) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/helper/plugin/grpc_provider.go:895 +0x7c5 github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler({0x1d68200, 0xc000006af0}, {0x1ffcef0, 0xc00018bb60}, 0xc0008b50e0, 0x0) github.com/hashicorp/terraform-plugin-sdk@v1.17.2/internal/tfplugin5/tfplugin5.pb.go:3305 +0x170 google.golang.org/grpc.(Server).processUnaryRPC(0xc0007f2380, {0x200e940, 0xc00036a000}, 0xc00029a600, 0xc0007e1c50, 0x27eb1c0, 0x0) google.golang.org/grpc@v1.32.0/server.go:1194 +0xc8f google.golang.org/grpc.(Server).handleStream(0xc0007f2380, {0x200e940, 0xc00036a000}, 0xc00029a600, 0x0) google.golang.org/grpc@v1.32.0/server.go:1517 +0xa2a google.golang.org/grpc.(Server).serveStreams.func1.2() google.golang.org/grpc@v1.32.0/server.go:859 +0x98 created by google.golang.org/grpc.(*Server).serveStreams.func1 google.golang.org/grpc@v1.32.0/server.go:857 +0x294

Error: The terraform-provider-panos_v1.11.1.exe plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely helpful if you could report the crash with the plugin's maintainers so that it can be fixed. The output above should help diagnose the issue.

Screenshots

here is my module code:

locals { static_routes = flatten([ for vr_name, vr in var.virtual_routers : [ for route_name, route in vr.static_routes : { vr_name = vr_name route_name = route_name route = route } ] ]) }

resource "panos_virtual_router" "this" { for_each = var.virtual_routers name = each.value.name template = panos_panorama_template.this[each.value.template_id].name interfaces = concat([for t in each.value.eth_interfaces : panos_panorama_ethernet_interface.this[t].name], contains(keys(each.value), "tunnel_interface") ? [each.value.tunnel_interface] : []) vsys = "vsys1" enable_ecmp = lookup(each.value, "enable_ecmp", null) ecmp_load_balance_method = lookup(each.value, "ecmp_load_balance_method", null) lifecycle { create_before_destroy = true } depends_on = [ panos_panorama_ethernet_interface.this ] }

resource "panos_static_route_ipv4" "this" { for_each = { for route in local.static_routes : "${route.vr_name}.${route.route_name}" => route }

name = each.value.route.name virtual_router = panos_virtual_router.this[each.value.vr_name].name interface = each.value.route.interface_name destination = each.value.route.destination next_hop = each.value.route.next_hop

lifecycle { create_before_destroy = true } }

welcome-to-palo-alto-networks[bot] commented 1 year ago

:tada: Thanks for opening your first issue here! Welcome to the community!

gvoden commented 1 year ago

we were using panos_ethernet_interface instead of panos_panorama_ethernet_interface in Panorama config which caused the above exception and crash