From b019c849152689618d3a24122e1537f189cfb919 Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Tue, 6 Feb 2018 14:44:06 -0800 Subject: [PATCH] Fixing a crash when the DhcpOptions aren't specifie --- azurerm/data_source_virtual_network.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/azurerm/data_source_virtual_network.go b/azurerm/data_source_virtual_network.go index ca8338cf1a86..167d6eaa6e28 100644 --- a/azurerm/data_source_virtual_network.go +++ b/azurerm/data_source_virtual_network.go @@ -77,9 +77,11 @@ func dataSourceArmVnetRead(d *schema.ResourceData, meta interface{}) error { return err } - dnsServers := flattenVnetAddressPrefixes(props.DhcpOptions.DNSServers) - if err := d.Set("dns_servers", dnsServers); err != nil { - return err + if options := props.DhcpOptions; options != nil { + dnsServers := flattenVnetAddressPrefixes(options.DNSServers) + if err := d.Set("dns_servers", dnsServers); err != nil { + return err + } } subnets := flattenVnetSubnetsNames(props.Subnets)