From f25cbb5c85567734d01cb8aed6b94a6a6ae0ae31 Mon Sep 17 00:00:00 2001 From: Simon Schneider Date: Wed, 2 Aug 2017 19:00:43 +0200 Subject: [PATCH] check if nic.NetworkInterfaceReferenceProperties.Primary field exists before trying to dereference it --- azurerm/resource_arm_virtual_machine.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/resource_arm_virtual_machine.go b/azurerm/resource_arm_virtual_machine.go index 8464a91a8cda..6725b9c4f805 100644 --- a/azurerm/resource_arm_virtual_machine.go +++ b/azurerm/resource_arm_virtual_machine.go @@ -701,7 +701,7 @@ func resourceArmVirtualMachineRead(d *schema.ResourceData, meta interface{}) err if resp.VirtualMachineProperties.NetworkProfile.NetworkInterfaces != nil { for _, nic := range *resp.VirtualMachineProperties.NetworkProfile.NetworkInterfaces { - if nic.NetworkInterfaceReferenceProperties != nil && *nic.NetworkInterfaceReferenceProperties.Primary { + if nic.NetworkInterfaceReferenceProperties != nil && nic.NetworkInterfaceReferenceProperties.Primary != nil && *nic.NetworkInterfaceReferenceProperties.Primary { d.Set("primary_network_interface_id", nic.ID) break }