From 857e5ffc9c0c1d2dc869e58242a04976d89ec9b4 Mon Sep 17 00:00:00 2001 From: Date: Wed, 1 Nov 2017 22:46:15 -0500 Subject: [PATCH] Nil refence fix for issue #464 --- azurerm/resource_arm_network_security_group.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/azurerm/resource_arm_network_security_group.go b/azurerm/resource_arm_network_security_group.go index 098deb001c97..3e8d3d2f98e5 100644 --- a/azurerm/resource_arm_network_security_group.go +++ b/azurerm/resource_arm_network_security_group.go @@ -226,10 +226,18 @@ func flattenNetworkSecurityRules(rules *[]network.SecurityRule) []interface{} { sgRule["name"] = *rule.Name if props := rule.SecurityRulePropertiesFormat; props != nil { - sgRule["destination_address_prefix"] = *props.DestinationAddressPrefix - sgRule["destination_port_range"] = *props.DestinationPortRange - sgRule["source_address_prefix"] = *props.SourceAddressPrefix - sgRule["source_port_range"] = *props.SourcePortRange + if props.DestinationAddressPrefix != nil { + sgRule["destination_address_prefix"] = *props.DestinationAddressPrefix + } + if props.DestinationPortRange != nil { + sgRule["destination_port_range"] = *props.DestinationPortRange + } + if props.SourceAddressPrefix != nil { + sgRule["source_address_prefix"] = *props.SourceAddressPrefix + } + if props.SourcePortRange != nil { + sgRule["source_port_range"] = *props.SourcePortRange + } sgRule["priority"] = int(*props.Priority) sgRule["access"] = string(props.Access) sgRule["direction"] = string(props.Direction)