PaloAltoNetworks / terraform-provider-panos

Terraform Panos provider
https://www.terraform.io/docs/providers/panos/
Mozilla Public License 2.0
87 stars 71 forks source link

Disassociate templates from template stack on destroy #262

Open ryanpodonnell1 opened 3 years ago

ryanpodonnell1 commented 3 years ago

Describe the bug

When a template is part of a template stack but is going to be destroyed as part of a plan it causes the apply to fail as its still apart of the parent template stack

Expected behavior

When a template is a part of a stack it should be disassociated then destroyed from the parent stack(s)

Current behavior

Terraform has been successfully initialized!
module.oci_external_hub_templates.panos_panorama_template.oci_template_ha["primary"]: Destroying... [id=OCI-TPL-DEV-HUB-EXTERNAL-PRIMARY-HA]
module.oci_internal_hub_templates.panos_panorama_template.oci_template_ha["primary"]: Destroying... [id=OCI-TPL-DEV-HUB-INTERNAL-PRIMARY-HA]
module.oci_external_hub_templates.panos_panorama_template.oci_template_ha["secondary"]: Destroying... [id=OCI-TPL-DEV-HUB-EXTERNAL-SECONDARY-HA]
module.oci_internal_hub_templates.panos_panorama_template.oci_template_ha["secondary"]: Destroying... [id=OCI-TPL-DEV-HUB-INTERNAL-SECONDARY-HA]

Error:  template-stack -> OCI-TPLS-DEV-HUB-INTERNAL-SECONDARY-FW -> templates

Error:  template-stack -> OCI-TPLS-DEV-HUB-EXTERNAL-SECONDARY-FW -> templates

Error:  template-stack -> OCI-TPLS-DEV-HUB-EXTERNAL-PRIMARY-FW -> templates

Error:  template-stack -> OCI-TPLS-DEV-HUB-INTERNAL-PRIMARY-FW -> templates

Possible solution

add an entry for force_detach = bool to the template resource to allow users to make the choice of whether to force a detach of the template from the stack

Steps to reproduce

  1. Create a template
  2. Assign template to stack
  3. force recreation or destroy the template while its still a part of the stack via a terraform apply

Context

forces me to go into panorama and manually disassociate the template to complete the build

shinmog commented 3 years ago

Can you share a simple Terraform plan that shows this issue?