diff --git a/builtin/providers/azurerm/resource_arm_network_interface_card.go b/builtin/providers/azurerm/resource_arm_network_interface_card.go index f2dbbed344cd..661332690c14 100644 --- a/builtin/providers/azurerm/resource_arm_network_interface_card.go +++ b/builtin/providers/azurerm/resource_arm_network_interface_card.go @@ -53,6 +53,12 @@ func resourceArmNetworkInterface() *schema.Resource { Computed: true, }, + "private_ip_address": &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "virtual_machine_id": &schema.Schema{ Type: schema.TypeString, Optional: true, @@ -241,7 +247,7 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e return nil } if err != nil { - return fmt.Errorf("Error making Read request on Azure Netowkr Interface %s: %s", name, err) + return fmt.Errorf("Error making Read request on Azure Network Interface %s: %s", name, err) } iface := *resp.Properties @@ -252,6 +258,17 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e } } + if iface.IPConfigurations != nil && len(*iface.IPConfigurations) > 0 { + var privateIPAddress *string + for _, ipConfig := range *iface.IPConfigurations { + privateIPAddress = ipConfig.Properties.PrivateIPAddress + } + + if *privateIPAddress != "" { + d.Set("private_ip_address", *privateIPAddress) + } + } + if iface.VirtualMachine != nil { if *iface.VirtualMachine.ID != "" { d.Set("virtual_machine_id", *iface.VirtualMachine.ID) diff --git a/website/source/docs/providers/azurerm/r/network_interface.html.markdown b/website/source/docs/providers/azurerm/r/network_interface.html.markdown index d2df6b9dbcee..a60a66c69df8 100644 --- a/website/source/docs/providers/azurerm/r/network_interface.html.markdown +++ b/website/source/docs/providers/azurerm/r/network_interface.html.markdown @@ -95,6 +95,7 @@ The following attributes are exported: * `id` - The virtual NetworkConfiguration ID. * `mac_address` - The media access control (MAC) address of the network interface. +* `private_ip_address` - The private ip address of the network interface. * `virtual_machine_id` - Reference to a VM with which this NIC has been associated. * `applied_dns_servers` - If the VM that uses this NIC is part of an Availability Set, then this list will have the union of all DNS servers from all NICs that are part of the Availability Set * `internal_fqdn` - Fully qualified DNS name supporting internal communications between VMs in the same VNet