Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug Fix: azurerm_virtual_network_peering prevent nil object from being read #4180

Merged
merged 3 commits into from
Aug 29, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions azurerm/resource_arm_virtual_network_peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,18 @@ func resourceArmVirtualNetworkPeeringRead(d *schema.ResourceData, meta interface
return fmt.Errorf("Error making Read request on Azure virtual network peering %q: %+v", name, err)
}

peer := *resp.VirtualNetworkPeeringPropertiesFormat

// update appropriate values
d.Set("resource_group_name", resGroup)
d.Set("name", resp.Name)
d.Set("virtual_network_name", vnetName)
d.Set("allow_virtual_network_access", peer.AllowVirtualNetworkAccess)
d.Set("allow_forwarded_traffic", peer.AllowForwardedTraffic)
d.Set("allow_gateway_transit", peer.AllowGatewayTransit)
d.Set("use_remote_gateways", peer.UseRemoteGateways)
d.Set("remote_virtual_network_id", peer.RemoteVirtualNetwork.ID)

if peer := resp.VirtualNetworkPeeringPropertiesFormat; peer != nil {
d.Set("allow_virtual_network_access", peer.AllowVirtualNetworkAccess)
d.Set("allow_forwarded_traffic", peer.AllowForwardedTraffic)
d.Set("allow_gateway_transit", peer.AllowGatewayTransit)
d.Set("use_remote_gateways", peer.UseRemoteGateways)
d.Set("remote_virtual_network_id", peer.RemoteVirtualNetwork.ID)
mbfrahry marked this conversation as resolved.
Show resolved Hide resolved
}

return nil
}
Expand Down