PaloAltoNetworks / terraform-provider-panos

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

PANOS panos_panorama_nat_rule_group trouble with target #290

Closed sarah-blazic closed 2 years ago

sarah-blazic commented 3 years ago

Describe the bug

Trying to create a NAT rule with a target firewall, results in errors.

Expected behavior

I expect it to create a NAT rule with a target firewall when I provide the serial number.

Current behavior

Resource is not created and throws the terraform-provider-panos_v1.8.3 exe plugin crashed! error.

Steps to reproduce

resource "panos_panorama_nat_rule_group" "this" {
  rule {
    name = "target"
    original_packet {
      destination_addresses = ["any"]
      destination_zone = "trust"
      source_addresses = ["any"]
      source_zones = ["untrust"]
    }
    translated_packet {
      destination {}
      source {}
    }

    target {
      serial = "1234567890"
    }
  }
}

Run terraform plan

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

panic: interface conversion: interface {} is *schema.Set, not []interface {}

goroutine 229 [running]:
github.com/terraform-providers/terraform-provider-panos/panos.resourceTargetHash(0xe5b500, 0xc000510840, 0x1007230)
        github.com/terraform-providers/terraform-provider-panos/panos/hashes.go:21 +0x25f
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Set).hash(0xc00027de40, 0xe5b500, 0xc000510840, 0x1, 0xc000777a40)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/set.go:221 +0x44
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Set).add(0xc00027de40, 0xe5b500, 0xc000510840, 0xc000777b00, 0x0, 0xc00018d680)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/set.go:198 +0x8b
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readSet(0xc0004e5da0, 0xc0005107e0, 0x3, 0x3, 0xc000777b80, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_config.go:309 +0x388
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readField(0xc0004e5da0, 0xc0005107e0, 0x3, 0x3, 0xe0e901, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_config.go:132 +0xb06
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*nestedConfigFieldReader).ReadField(0xc0009dcc88, 0xc0005107e0, 0x3, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_config.go:352 +0xa8
github.com/hashicorp/terraform-plugin-sdk/helper/schema.readObjectField(0x11667e0, 0xc0009dcc88, 0xc00027dcc0, 0x2, 0x2, 0xc00076a0c0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader.go:244 +0x21a
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readField(0xc0004e5da0, 0xc00027dcc0, 0x2, 0x2, 0xe3dc01, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_config.go:134 +0x9f7
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*nestedConfigFieldReader).ReadField(0xc0009dcc78, 0xc00027dcc0, 0x2, 0x2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_config.go:352 +0xa8
github.com/hashicorp/terraform-plugin-sdk/helper/schema.readListField(0x11667e0, 0xc0009dcc78, 0xc00082d3d0, 0x1, 0x1, 0xc000777400, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader.go:211 +0x37f
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).readField(0xc0004e5da0, 0xc00082d3d0, 0x1, 0x1, 0x8dd900, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_config.go:128 +0x69e
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ConfigFieldReader).ReadField(0xc0004e5da0, 0xc00082d3d0, 0x1, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xe2eb40, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_config.go:28 +0xd3
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*MultiLevelFieldReader).ReadFieldExact(0xc00027dc80, 0xc00082d3d0, 0x1, 0x1, 0xfb4a8b, 0x6, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/field_reader_multi.go:31 +0xf6
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).get(0xc000223260, 0xc00082d3d0, 0x1, 0x1, 0x12, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/resource_data.go:534 +0x129
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).getChange(0xc000223260, 0xfb319f, 0x4, 0x1201, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/resource_data.go:510 +0x12a
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*ResourceData).diffChange(0xc000223260, 0xfb319f, 0x4, 0x0, 0xc0001a0ec0, 0x90d13f, 0x4, 0xe0e920)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/resource_data.go:487 +0xa6
github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.diffList(0xc00076a090, 0xfb319f, 0x4, 0xc000777400, 0xc000561390, 0x11833e8, 0xc000223260, 0x1146900, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/schema.go:958 +0x75
github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.diff(0xc00076a090, 0xfb319f, 0x4, 0xc000777400, 0xc00027dc40, 0x11833e8, 0xc000223260, 0xe0e900, 0x0, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/schema.go:919 +0x473
github.com/hashicorp/terraform-plugin-sdk/helper/schema.schemaMap.Diff(0xc00076a090, 0xc00082e280, 0xc0004e5470, 0x0, 0xfa9aa0, 0xc00013e540, 0xc00018d200, 0x0, 0xe0e920, 0xe0e920)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/schema.go:500 +0x239
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).simpleDiff(0xc00074ba00, 0xc00082e280, 0xc0004e5470, 0xfa9aa0, 0xc00013e540, 0xc0004e5401, 0xc0001a1740, 0xef554)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/resource.go:351 +0x8c
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).SimpleDiff(0xc00020a080, 0xc0001a1948, 0xc00082e280, 0xc0004e5470, 0xc00023bc80, 0xc0004e5470, 0x0)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/helper/schema/provider.go:321 +0xa5
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).PlanResourceChange(0xc0000060b0, 0x117f1f0, 0xc000041500, 0xc0001819e0, 0xc0000060b0, 0xc000041500, 0xc00061ba50)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/internal/helper/plugin/grpc_provider.go:633 +0x765
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_PlanResourceChange_Handler(0xf72d40, 0xc0000060b0, 0x117f1f0, 0xc000041500, 0xc000181980, 0x0, 0x117f1f0, 0xc000041500, 0xc000381000, 0x3ce)
        github.com/hashicorp/terraform-plugin-sdk@v1.4.0/internal/tfplugin5/tfplugin5.pb.go:3171 +0x222
google.golang.org/grpc.(*Server).processUnaryRPC(0xc000470160, 0x1187538, 0xc000192300, 0xc0001c0700, 0xc00068b9b0, 0x178bb48, 0x0, 0x0, 0x0)
        google.golang.org/grpc@v1.23.0/server.go:995 +0x482
google.golang.org/grpc.(*Server).handleStream(0xc000470160, 0x1187538, 0xc000192300, 0xc0001c0700, 0x0)
        google.golang.org/grpc@v1.23.0/server.go:1275 +0xd4c
google.golang.org/grpc.(*Server).serveStreams.func1.1(0xc0002021c0, 0xc000470160, 0x1187538, 0xc000192300, 0xc0001c0700)
        google.golang.org/grpc@v1.23.0/server.go:710 +0xb2
created by google.golang.org/grpc.(*Server).serveStreams.func1
        google.golang.org/grpc@v1.23.0/server.go:708 +0xa8

Error: The terraform-provider-panos_v1.8.3.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.

Your Environment

Terraform v0.15.3
on windows_amd64
+ provider registry.terraform.io/paloaltonetworks/panos v1.8.3
welcome-to-palo-alto-networks[bot] commented 3 years ago

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

45413 commented 3 years ago

It turns out this is not limited to attempting to create new a new resource with a target in terraform, but you can also reproduce this issue if you attempt to do a terraform refresh/plan when a nat rule has been modified outside of terraform and assigned specific targets.