trois-six / terraformer

CLI tool to generate terraform files from existing infrastructure (reverse Terraform). Infrastructure to Code
Apache License 2.0
1 stars 2 forks source link

"panic" during firewall_policy import #2

Closed jamesholland-uk closed 3 years ago

jamesholland-uk commented 3 years ago

Running import of firewall_policy causes a panic error, see error details below. Appears to not be linked to a specific rule. firewall_objects and device_config execute perfectly.

System Details:

Error details:

$ terraformer import panos --resources=firewall_policy
2021/07/05 21:06:05 panos importing VSYS vsys1
2021/07/05 21:06:08 panos importing... firewall_policy
2021/07/05 21:06:10 panos done importing firewall_policy
2021/07/05 21:06:10 Number of resources for service firewall_policy: 29
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--unifi_provisioning
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--block_malicious
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--zoom_outbound_by_edl
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--kids_ipads_outbound_catch
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--tunnel_to_prisma_access
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--managemt_of_unifi
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--initial_home_iot_conduit
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--gp_to_internet
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--initial_iot_home_conduit
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--gp_to_home
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--from_ldn_lab_prisma_access
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--team_and_skype_outbound_by_edl
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--tap_for_iot
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--internet_intrazone_deny
2021/07/05 21:06:10 Refreshing state... panos_security_rule_group.tfer--clientless_to_internet
2021/07/05 21:06:14 Refreshing state... panos_security_rule_group.tfer--unifi_access_to_dns_server
2021/07/05 21:06:14 Refreshing state... panos_security_rule_group.tfer--catch_sinkhole
2021/07/05 21:06:15 Refreshing state... panos_nat_rule_group.tfer--outbound_hide
2021/07/05 21:06:15 Refreshing state... panos_nat_rule_group.tfer--local_no_nat
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--general_outbound
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--perimeter_edge_gp_inbound
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--block_quic
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--perimeter_edge_outbound
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--testbed_outbound
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--clientless_to_home
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--gather_host_id
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--to_ldn_lab_prisma_access
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--general_outbound_all_ports
2021/07/05 21:06:15 Refreshing state... panos_security_rule_group.tfer--kids_ipads_outbound_apps
panic: interface conversion: interface {} is nil, not []interface {}

goroutine 1 [running]:
github.com/GoogleCloudPlatform/terraformer/providers/panos.(*FirewallPolicyGenerator).PostConvertHook(0xc00030c700, 0xb75d9d8, 0xc00030c700)
    github.com/GoogleCloudPlatform/terraformer/providers/panos/firewall_policy.go:86 +0x727
github.com/GoogleCloudPlatform/terraformer/terraformutils.(*ProvidersMapping).CleanupProviders(0xc001d078d8)
    github.com/GoogleCloudPlatform/terraformer/terraformutils/providers_mapping.go:175 +0xee
github.com/GoogleCloudPlatform/terraformer/cmd.Import(0xb742440, 0xc000fa8f80, 0xc000f04760, 0x1, 0x1, 0x104e88b0, 0x0, 0x0, 0xc0003d2a80, 0x24, ...)
    github.com/GoogleCloudPlatform/terraformer/cmd/import.go:104 +0x370
github.com/GoogleCloudPlatform/terraformer/cmd.newCmdPanosImporter.func1(0xc000d862c0, 0xc000f04300, 0x0, 0x1, 0x0, 0x0)
    github.com/GoogleCloudPlatform/terraformer/cmd/provider_cmd_panos.go:49 +0x358
github.com/spf13/cobra.(*Command).execute(0xc000d862c0, 0xc000f042f0, 0x1, 0x1, 0xc000d862c0, 0xc000f042f0)
    github.com/spf13/cobra@v1.1.1/command.go:850 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc000c7eb00, 0xc000c22110, 0xc000116050, 0xaaee7f0)
    github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.1.1/command.go:895
github.com/GoogleCloudPlatform/terraformer/cmd.Execute(0xb5460e0, 0xc000c22110)
    github.com/GoogleCloudPlatform/terraformer/cmd/root.go:36 +0x2a
main.main()
    github.com/GoogleCloudPlatform/terraformer/main.go:39 +0x65

$ terraformer import panos --resources=firewall_policy
2021/07/05 21:06:26 panos importing VSYS vsys1
2021/07/05 21:06:29 panos importing... firewall_policy
2021/07/05 21:06:31 panos done importing firewall_policy
2021/07/05 21:06:31 Number of resources for service firewall_policy: 29
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--kids_ipads_outbound_catch
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--block_quic
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--internet_intrazone_deny
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--tunnel_to_prisma_access
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--gp_to_home
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--clientless_to_home
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--kids_ipads_outbound_apps
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--perimeter_edge_gp_inbound
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--from_ldn_lab_prisma_access
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--managemt_of_unifi
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--to_ldn_lab_prisma_access
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--general_outbound_all_ports
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--unifi_provisioning
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--team_and_skype_outbound_by_edl
2021/07/05 21:06:31 Refreshing state... panos_security_rule_group.tfer--clientless_to_internet
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--gather_host_id
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--catch_sinkhole
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--general_outbound
2021/07/05 21:06:35 Refreshing state... panos_nat_rule_group.tfer--local_no_nat
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--perimeter_edge_outbound
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--zoom_outbound_by_edl
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--initial_home_iot_conduit
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--tap_for_iot
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--initial_iot_home_conduit
2021/07/05 21:06:35 Refreshing state... panos_nat_rule_group.tfer--outbound_hide
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--unifi_access_to_dns_server
2021/07/05 21:06:35 Refreshing state... panos_security_rule_group.tfer--testbed_outbound
2021/07/05 21:06:36 Refreshing state... panos_security_rule_group.tfer--block_malicious
2021/07/05 21:06:36 Refreshing state... panos_security_rule_group.tfer--gp_to_internet
panic: interface conversion: interface {} is nil, not []interface {}

goroutine 1 [running]:
github.com/GoogleCloudPlatform/terraformer/providers/panos.(*FirewallPolicyGenerator).PostConvertHook(0xc001cf4780, 0xb75d9d8, 0xc001cf4780)
    github.com/GoogleCloudPlatform/terraformer/providers/panos/firewall_policy.go:86 +0x727
github.com/GoogleCloudPlatform/terraformer/terraformutils.(*ProvidersMapping).CleanupProviders(0xc001ef18d8)
    github.com/GoogleCloudPlatform/terraformer/terraformutils/providers_mapping.go:175 +0xee
github.com/GoogleCloudPlatform/terraformer/cmd.Import(0xb742440, 0xc001768180, 0xc0003f04c0, 0x1, 0x1, 0x104e88b0, 0x0, 0x0, 0xc000312300, 0x24, ...)
    github.com/GoogleCloudPlatform/terraformer/cmd/import.go:104 +0x370
github.com/GoogleCloudPlatform/terraformer/cmd.newCmdPanosImporter.func1(0xc0014abb80, 0xc0013054c0, 0x0, 0x1, 0x0, 0x0)
    github.com/GoogleCloudPlatform/terraformer/cmd/provider_cmd_panos.go:49 +0x358
github.com/spf13/cobra.(*Command).execute(0xc0014abb80, 0xc0013054b0, 0x1, 0x1, 0xc0014abb80, 0xc0013054b0)
    github.com/spf13/cobra@v1.1.1/command.go:850 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0xc001224580, 0xc0010fbb20, 0xc000110050, 0xaaee7f0)
    github.com/spf13/cobra@v1.1.1/command.go:958 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
    github.com/spf13/cobra@v1.1.1/command.go:895
github.com/GoogleCloudPlatform/terraformer/cmd.Execute(0xb5460e0, 0xc0010fbb20)
    github.com/GoogleCloudPlatform/terraformer/cmd/root.go:36 +0x2a
main.main()
    github.com/GoogleCloudPlatform/terraformer/main.go:39 +0x65

$ 
trois-six commented 3 years ago

Here we are in an edge case. The problem happens when I try to replace a hardcoded string dumped by Terraform with a Terraform variable in the post convert hook. That will be easy to fix I think.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

trois-six commented 3 years ago

Corrected also in the final PR I made to upstream.