terraform-routeros / terraform-provider-routeros

Terraform Provider for Mikrotik RouterOS
Mozilla Public License 2.0
185 stars 53 forks source link

Need new filed 'randomise_ports' in action 'endpoint-independent-nat' #520

Closed zealic closed 1 month ago

zealic commented 1 month ago

Thanks for your hardwork. 👍

Describe the bug Related to #516, need new filed 'randomise_ports' in action 'endpoint-independent-nat' for routeros_ip_firewall_nat resource.

To Reproduce

variable "rules_nat_pit" {
  type = list(object({
    comment            = string
    chain              = string
    action             = string
    in_interface       = optional(string, null)
    out_interface      = optional(string, null)
    in_interface_list  = optional(string, null)
    out_interface_list = optional(string, null)
    protocol           = optional(string, null)
    src_address_list   = optional(string, null)
    dst_address_list   = optional(string, null)
    src_address        = optional(string, null)
    dst_address        = optional(string, null)
    src_port           = optional(string, null)
    dst_port           = optional(string, null)
    log                = optional(bool, false)
    disabled           = optional(bool, true)
  }))

  default = [
    {
      comment            = "[PIT] Fullcone NAT - OUT"
      action             = "endpoint-independent-nat"
      chain              = "srcnat"
      out_interface_list = "PIT"
      protocol           = "udp"
      disabled           = false
    },
    {
      comment           = "[PIT] Fullcone NAT - IN"
      action            = "endpoint-independent-nat"
      chain             = "dstnat"
      in_interface_list = "PIT"
      protocol          = "udp"
      disabled          = false
    }
  ]
}

locals {
  rules_nat_pit_map = { for idx, rule in var.rules_nat_pit : format("%03d", idx) => rule }
}

resource "routeros_interface_list" "interface-list-pit" {
  name = "PIT"
}

resource "routeros_ip_firewall_nat" "rules_nat_pit" {
  for_each           = local.rules_nat_pit_map
  comment            = each.value.comment
  chain              = each.value.chain
  action             = each.value.action
  in_interface       = each.value.in_interface
  out_interface      = each.value.out_interface
  in_interface_list  = each.value.in_interface_list
  out_interface_list = each.value.out_interface_list
  protocol           = each.value.protocol
  src_address        = each.value.src_address
  dst_address        = each.value.dst_address
  src_address_list   = each.value.src_address_list
  dst_address_list   = each.value.dst_address_list
  src_port           = each.value.src_port
  dst_port           = each.value.dst_port
  log                = each.value.log
  disabled           = each.value.disabled
  depends_on = [
    routeros_interface_list.interface-list-pit
  ]
}

resource "routeros_move_items" "rules_nat_pit_sorter" {
  #  resource_name = "routeros_ip_firewall_nat"
  resource_path = "/ip/firewall/nat"
  sequence      = [for i, _ in local.rules_nat_pit_map : routeros_ip_firewall_nat.rules_nat_pit[i].id]
  depends_on    = [routeros_ip_firewall_nat.rules_nat_pit]
}

Expected behavior Not field not found warning message.

Debug Information

Apply this code, and re-apply will got warning message:

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
╷
│ Warning: Field 'randomise_ports' not found in the schema
│ 
│   with routeros_ip_firewall_nat.rules_nat_pit["000"],
│   on 202-firewall-nat-pit.tf line 62, in resource "routeros_ip_firewall_nat" "rules_nat_pit":
│   62: resource "routeros_ip_firewall_nat" "rules_nat_pit" {
│ 
│ [MikrotikResourceDataToTerraform] The field was lost during the Schema development: ▷ 'randomise_ports': 'false' ◁
│ 
│ (and 3 more similar warnings elsewhere)

Stack Trace N/A

Additional context N/A

vaerh commented 1 month ago

You're welcome! The MT documentation specifies the name randomize-port, but for now I will add the attribute according to what is specified in the output. Something should obviously change in the future....

vaerh commented 1 month ago

:tada: This issue has been resolved in version 1.58.2 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: