PaloAltoNetworks / terraform-provider-sase

Terraform provider for SASE API
Apache License 2.0
1 stars 2 forks source link

Terraform Destroy Fails #3

Closed ancoleman closed 1 year ago

ancoleman commented 1 year ago

Describe the bug

Terraform Destroy fails to destroy resources

Expected behavior

When running terraform destroy, a resource should be destroyed.

Current behavior

When running terraform destroy, a resource fails to destroy with error: ["folder" is required]

Possible solution

Steps to reproduce

venv) (base) acoleman@M-KGYXTTH2MF remote_networks % terraform apply --auto-approve
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - paloaltonetworks-local/sase in /Users/acoleman/Documents/Projects/PracticeDevelopment/github/terraform-provider-sase
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # sase_remote_networks.this will be created
  + resource "sase_remote_networks" "this" {
      + ecmp_load_balancing = "disable"
      + folder              = "Remote Networks"
      + id                  = (known after apply)
      + ipsec_tunnel        = "AWS-VM-1-IPSEC-TUNNEL"
      + license_type        = "FWAAS-AGGREGATE"
      + name                = "terraform-rn-1"
      + object_id           = (known after apply)
      + region              = "us-southeast"
      + spn_name            = "us-southeast-amaryllis"
    }

Plan: 1 to add, 0 to change, 0 to destroy.
sase_remote_networks.this: Creating...
sase_remote_networks.this: Creation complete after 1s [id=Remote Networks:6516a5c5-3a57-497b-9cb2-c0ae0af6b562]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
(venv) (base) acoleman@M-KGYXTTH2MF remote_networks % terraform destroy       
╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - paloaltonetworks-local/sase in /Users/acoleman/Documents/Projects/PracticeDevelopment/github/terraform-provider-sase
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published releases.
╵
sase_remote_networks.this: Refreshing state... [id=Remote Networks:6516a5c5-3a57-497b-9cb2-c0ae0af6b562]
╷
│ Error: Error reading config
│ 
│   with sase_remote_networks.this,
│   on main.tf line 80, in resource "sase_remote_networks" "this":
│   80: resource "sase_remote_networks" "this" {
│ 
│ [HTTP 400] API_I00035 Invalid Request Payload  - ["folder" is required]

Screenshots

Context

Your Environment

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

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

ancoleman commented 1 year ago

This issue seems to affect both destroy, apply, and plan operations once a resource has been built. I did validate that in the TFSTATE that the folder attribute lives, so it must be how we process and look for the folder attribute that is causing the problem.

shinmog commented 1 year ago

This error is coming from the API...

This looks to be similar to the error I was getting with address objects: the API requires the folder param, but the spec I was given says only the UUID is required. I'll override this and add in the folder param for Read / Update / Delete. You'll need to git pull the SDK and this repo for the fix.

shinmog commented 1 year ago

Ok, so it's possible that just the Read function needed the folder param, which would make it exactly like the address object issue. Please try all CRUD functions and see if they work. If something is still broken just reopen this issue and tell me what shouldn't get the folder param.

ancoleman commented 1 year ago

After pulling the latest the provider build fails:

venv) (base) acoleman@M-KGYXTTH2MF terraform-provider-sase % go build
# [github.com/paloaltonetworks/terraform-provider-sase/internal/provider](http://github.com/paloaltonetworks/terraform-provider-sase/internal/provider)
internal/provider/ike_gateways.go:879:3: unknown field Folder in struct literal of type ikegateways.ReadInput
internal/provider/ike_gateways.go:893:30: input.Folder undefined (type ikegateways.ReadInput has no field or method Folder)
internal/provider/ike_gateways.go:1647:3: unknown field Folder in struct literal of type ikegateways.ReadInput