From 6732659fe9d1ee718c523037ed21215d82e0f5f8 Mon Sep 17 00:00:00 2001 From: James Nugent Date: Mon, 21 Mar 2016 13:45:57 +0000 Subject: [PATCH] provider/aws: Fix panic in VPN connection resource Check to ensure that vpnConnection.CustomerGatewayConfiguration is not nil prior to dereferencing it on read. Fixes #5647. --- builtin/providers/aws/resource_aws_vpn_connection.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/builtin/providers/aws/resource_aws_vpn_connection.go b/builtin/providers/aws/resource_aws_vpn_connection.go index f8d8b8fd874b..60fb33e2804f 100644 --- a/builtin/providers/aws/resource_aws_vpn_connection.go +++ b/builtin/providers/aws/resource_aws_vpn_connection.go @@ -305,11 +305,13 @@ func resourceAwsVpnConnectionRead(d *schema.ResourceData, meta interface{}) erro // Set read only attributes. d.Set("customer_gateway_configuration", vpnConnection.CustomerGatewayConfiguration) - tunnelInfo := xmlConfigToTunnelInfo(*vpnConnection.CustomerGatewayConfiguration) - d.Set("tunnel1_address", tunnelInfo.Tunnel1Address) - d.Set("tunnel1_preshared_key", tunnelInfo.Tunnel1PreSharedKey) - d.Set("tunnel2_address", tunnelInfo.Tunnel2Address) - d.Set("tunnel2_preshared_key", tunnelInfo.Tunnel2PreSharedKey) + if vpnConnection.CustomerGatewayConfiguration != nil { + tunnelInfo := xmlConfigToTunnelInfo(*vpnConnection.CustomerGatewayConfiguration) + d.Set("tunnel1_address", tunnelInfo.Tunnel1Address) + d.Set("tunnel1_preshared_key", tunnelInfo.Tunnel1PreSharedKey) + d.Set("tunnel2_address", tunnelInfo.Tunnel2Address) + d.Set("tunnel2_preshared_key", tunnelInfo.Tunnel2PreSharedKey) + } if err := d.Set("vgw_telemetry", telemetryToMapList(vpnConnection.VgwTelemetry)); err != nil { return err