cisco-open / terraform-provider-meraki

A Terraform Provider for Cisco Meraki
Mozilla Public License 2.0
17 stars 7 forks source link

meraki_networks_switch_access_policies destroy fails because meraki_devices_switch_ports delete is no-op #172

Closed joekohlsdorf closed 3 weeks ago

joekohlsdorf commented 1 month ago

Describe the bug

Now try to run terraform destroy, you'll get the following response from the API when trying to destroy the access policy after the switch port is destroyed:

{
    "errors": [
       "This access policy is in use by 1 port. An access policy can only be removed if it is not in use."
    ]
}

Expected behavior destroy on a switch port should not be a no-op, instead some kind of default configuration which doesn't depend on any other resources is restored. This could also be a security issue because users of the provider might expect access policies to be removed from ports when the ports are destroyed.

A user should not be expected to reconfigure the switch ports before being able to destroy a network.

Environment (please complete the following information):

fmunozmiranda commented 1 month ago

Hi @joekohlsdorf , could you pass us the provider debug

obrigg commented 1 month ago

Hi Joe, The Meraki Terraform Provider is replicating the behavior of our API operations. As you noticed, a requirement for deleting an access policy is having no ports associated with that policy. We try to avoid breaking changes in our API behavior. When we start planning version 2 of Dashboard API (some time in the future - no dates yet), these kind of behavior changes will be taken into consideration.

Removing a port's association with an access policy can be done using meraki_devices_switch_ports:

resource "meraki_devices_switch_ports" "this_switch_port" {
  serial                    = "XXX"
  access_policy_type        = "Open"
  port_id                   = 1
}
joekohlsdorf commented 1 month ago

Hi @obrigg, In my opinion the current Dashboard API is sufficient, you could give users optional configuration parameters to specify what should be done with the configuration of the ports on destroy. An example provider which does this is terracurl, it isn't pretty but it works and it's definitely better than having to change the configuration before being able to destroy a network.

obrigg commented 4 weeks ago

Thank you for the feedback. I will make sure the relevant team is aware of it. Does this answer your question about the current behavior?

fmunozmiranda commented 3 weeks ago

Closed due inactivity.