diff --git a/routeros/mikrotik_serialize.go b/routeros/mikrotik_serialize.go index b4b8b26b..3f6bfa14 100644 --- a/routeros/mikrotik_serialize.go +++ b/routeros/mikrotik_serialize.go @@ -194,6 +194,11 @@ func TerraformResourceDataToMikrotik(s map[string]*schema.Schema, d *schema.Reso switch terraformMetadata.Type { case schema.TypeString: + if _, ok := setUnsetFields[terraformSnakeName]; ok && value.(string) == "" { + // Unset + item["!"+mikrotikKebabName] = "" + continue + } item[mikrotikKebabName] = value.(string) case schema.TypeFloat: item[mikrotikKebabName] = strconv.FormatFloat(value.(float64), 'f', -1, 64) diff --git a/routeros/resource_ip_firewall_filter.go b/routeros/resource_ip_firewall_filter.go index 670cde6d..1a26ad0b 100644 --- a/routeros/resource_ip_firewall_filter.go +++ b/routeros/resource_ip_firewall_filter.go @@ -12,9 +12,10 @@ import ( // ResourceIPFirewallFilter https://wiki.mikrotik.com/wiki/Manual:IP/Firewall/Filter func ResourceIPFirewallFilter() *schema.Resource { resSchema := map[string]*schema.Schema{ - MetaResourcePath: PropResourcePath("/ip/firewall/filter"), - MetaId: PropId(Id), - MetaSkipFields: PropSkipFields(`"bytes","packets"`), + MetaResourcePath: PropResourcePath("/ip/firewall/filter"), + MetaId: PropId(Id), + MetaSkipFields: PropSkipFields(`"bytes","packets"`), + MetaSetUnsetFields: PropSetUnsetFields(`"dst_address_list","src_address_list","in_interface_list","out_interface_list","in_bridge_port_list","out_bridge_port_list"`), "action": { Type: schema.TypeString, diff --git a/routeros/resource_ip_firewall_mangle.go b/routeros/resource_ip_firewall_mangle.go index 1a7c99ea..89122c0f 100644 --- a/routeros/resource_ip_firewall_mangle.go +++ b/routeros/resource_ip_firewall_mangle.go @@ -27,9 +27,10 @@ import ( // ResourceIPFirewallMangle https://wiki.mikrotik.com/wiki/Manual:IP/Firewall/Mangle func ResourceIPFirewallMangle() *schema.Resource { resSchema := map[string]*schema.Schema{ - MetaResourcePath: PropResourcePath("/ip/firewall/mangle"), - MetaId: PropId(Id), - MetaSkipFields: PropSkipFields(`"bytes","packets"`), + MetaResourcePath: PropResourcePath("/ip/firewall/mangle"), + MetaId: PropId(Id), + MetaSkipFields: PropSkipFields(`"bytes","packets"`), + MetaSetUnsetFields: PropSetUnsetFields(`"dst_address_list","src_address_list","in_interface_list","out_interface_list","in_bridge_port_list","out_bridge_port_list"`), "action": { Type: schema.TypeString, diff --git a/routeros/resource_ip_firewall_nat.go b/routeros/resource_ip_firewall_nat.go index 1870e33e..1be60206 100644 --- a/routeros/resource_ip_firewall_nat.go +++ b/routeros/resource_ip_firewall_nat.go @@ -29,9 +29,10 @@ import ( // ResourceIPFirewallNat https://wiki.mikrotik.com/wiki/Manual:IP/Firewall/NAT func ResourceIPFirewallNat() *schema.Resource { resSchema := map[string]*schema.Schema{ - MetaResourcePath: PropResourcePath("/ip/firewall/nat"), - MetaId: PropId(Id), - MetaSkipFields: PropSkipFields(`"bytes","packets"`), + MetaResourcePath: PropResourcePath("/ip/firewall/nat"), + MetaId: PropId(Id), + MetaSkipFields: PropSkipFields(`"bytes","packets"`), + MetaSetUnsetFields: PropSetUnsetFields(`"dst_address_list","src_address_list","in_interface_list","out_interface_list","in_bridge_port_list","out_bridge_port_list"`), "action": { Type: schema.TypeString,