title: Terraform retrieve inbound NAT rules ports
body: <p>I'm deploying infrastructure on Azure using Terraform,
  I'm using modules for a linux scale set an a load balancer and using <code>azurerm_lb_nat_pool</code> in order to have SSH access to the VMs,
  I have a need now to retrieve the ports of the NAT rules for other purposes.</p>
  <p>For the life of me I cannot find a way to retrieve them, went through all the terraform documentation and cannot find it under any <code>data</code> source or attribute reference.</p>
  <p>Here is my LB code:</p>
  <pre><code>resource &quot;azurerm_lb&quot; &quot;front-load-balancer&quot; {
    name                = &quot;front-load-balancer&quot;
    location            = var.def-location
    resource_group_name = var.rg-name
    sku                 = &quot;Standard&quot;
  
    
    frontend_ip_configuration {
      name                 = &quot;frontend-IP-configuration&quot;
      public_ip_address_id = var.public-ip-id
    }
  }
  
  resource &quot;azurerm_lb_nat_pool&quot; &quot;lb-nat-pool&quot; {
    resource_group_name            = var.rg-name
    loadbalancer_id                = azurerm_lb.front-load-balancer.id
    name                           = &quot;lb-nat-pool&quot;
    protocol                       = &quot;Tcp&quot;
    frontend_port_start            = var.frontend-port-start
    frontend_port_end              = var.frontend-port-end
    backend_port                   = 22
    frontend_ip_configuration_name = &quot;frontend-IP-configuration&quot;
  }
  </code></pre>
  <p>Any assistance would be very appreciated.</p>
  <p>EDIT:
  I tried exporting the <code>inbound_nat_rules</code> export on the <code>azurerm_lb</code> frontend IP configuration, it gives a list of the resources which I do not currently know how to extract the ports from::</p>
  <pre><code>output &quot;frontend-ip-confguration-inbound-nat-rules&quot; {
    value = azurerm_lb.front-load-balancer.frontend_ip_configuration[*].inbound_nat_rules
  }
  </code></pre>
  <p>Which results in this:</p>
  <pre><code>Changes to Outputs:
    + LB-frontend-IP-confguration-Inbound-nat-rules = [
        + [
            + &quot;/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/weight-tracker-stage-rg/providers/Microsoft.Network/loadBalancers/front-load-balancer/inboundNatRules/lb-nat-pool.3&quot;,
            + &quot;/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/weight-tracker-stage-rg/providers/Microsoft.Network/loadBalancers/front-load-balancer/inboundNatRules/lb-nat-pool.4&quot;,
            + &quot;/subscriptions/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/resourceGroups/weight-tracker-stage-rg/providers/Microsoft.Network/loadBalancers/front-load-balancer/inboundNatRules/lb-nat-pool.6&quot;,
          ],
      ]
  </code></pre>