From e12ca5b4188e9b1df95afc78edc7fb31da4cb2c0 Mon Sep 17 00:00:00 2001 From: Thiery Ouattara Date: Wed, 4 Sep 2024 15:02:08 +0000 Subject: [PATCH] Check httpResponse when destroying vpn_connection --- outscale/resource_outscale_vpn_connection.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/outscale/resource_outscale_vpn_connection.go b/outscale/resource_outscale_vpn_connection.go index ed90789b1..9e9723ef1 100644 --- a/outscale/resource_outscale_vpn_connection.go +++ b/outscale/resource_outscale_vpn_connection.go @@ -272,12 +272,16 @@ func vpnConnectionRefreshFunc(conn *oscgo.APIClient, vpnConnectionID *string) re } resp, httpResp, err := conn.VpnConnectionApi.ReadVpnConnections(context.Background()).ReadVpnConnectionsRequest(filter).Execute() if err != nil { - switch { - case httpResp.StatusCode == http.StatusServiceUnavailable: - return nil, "pending", nil - case httpResp.StatusCode == http.StatusNotFound: - return nil, "deleted", nil - default: + if httpResp != nil { + switch { + case httpResp.StatusCode == http.StatusServiceUnavailable: + return nil, "pending", nil + case httpResp.StatusCode == http.StatusNotFound: + return nil, "deleted", nil + default: + return nil, "failed", fmt.Errorf("Error on vpnConnectionRefresh: %s", err) + } + } else { return nil, "failed", fmt.Errorf("Error on vpnConnectionRefresh: %s", err) } }