Skip to content

Commit 156d291

Browse files
Felivelstack72
authored andcommitted
Adding private ip address reference to azurerm network interface (hashicorp#6538)
* Adding private ip address reference * adding private ip address reference * Updating the docs. * Removing optional attrib from private_ip_address Removing optional attribute from private_ip_address, this element is only being used in the read. * Selecting the first element instead of using a loop for now. Change this to a loop when Azure/azure-sdk-for-go#259 is fixed
1 parent 35c4daf commit 156d291

2 files changed

Lines changed: 19 additions & 1 deletion

File tree

builtin/providers/azurerm/resource_arm_network_interface_card.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ func resourceArmNetworkInterface() *schema.Resource {
5353
Computed: true,
5454
},
5555

56+
"private_ip_address": &schema.Schema{
57+
Type: schema.TypeString,
58+
Computed: true,
59+
},
60+
5661
"virtual_machine_id": &schema.Schema{
5762
Type: schema.TypeString,
5863
Optional: true,
@@ -241,7 +246,7 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e
241246
return nil
242247
}
243248
if err != nil {
244-
return fmt.Errorf("Error making Read request on Azure Netowkr Interface %s: %s", name, err)
249+
return fmt.Errorf("Error making Read request on Azure Network Interface %s: %s", name, err)
245250
}
246251

247252
iface := *resp.Properties
@@ -252,6 +257,18 @@ func resourceArmNetworkInterfaceRead(d *schema.ResourceData, meta interface{}) e
252257
}
253258
}
254259

260+
if iface.IPConfigurations != nil && len(*iface.IPConfigurations) > 0 {
261+
var privateIPAddress *string
262+
///TODO: Change this to a loop when https://github.com/Azure/azure-sdk-for-go/issues/259 is fixed
263+
if (*iface.IPConfigurations)[0].Properties != nil {
264+
privateIPAddress = (*iface.IPConfigurations)[0].Properties.PrivateIPAddress
265+
}
266+
267+
if *privateIPAddress != "" {
268+
d.Set("private_ip_address", *privateIPAddress)
269+
}
270+
}
271+
255272
if iface.VirtualMachine != nil {
256273
if *iface.VirtualMachine.ID != "" {
257274
d.Set("virtual_machine_id", *iface.VirtualMachine.ID)

website/source/docs/providers/azurerm/r/network_interface.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ The following attributes are exported:
9595

9696
* `id` - The virtual NetworkConfiguration ID.
9797
* `mac_address` - The media access control (MAC) address of the network interface.
98+
* `private_ip_address` - The private ip address of the network interface.
9899
* `virtual_machine_id` - Reference to a VM with which this NIC has been associated.
99100
* `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
100101
* `internal_fqdn` - Fully qualified DNS name supporting internal communications between VMs in the same VNet

0 commit comments

Comments
 (0)