From 0e5601e5682cf3a18b46505c9300e11561caf38e Mon Sep 17 00:00:00 2001 From: Jay Wang Date: Wed, 29 Mar 2017 11:49:38 -0700 Subject: [PATCH] Fix crash in import azurerm_local_network_gateway The plug-in crashes if "localNetworkGateways" is not found in the id parameter. The fix is to verify the parameter before proceeding. Also the "import" example in the documentation is wrong, "localNetworkGateways" should be case sensitive. The current example actually causes the plugin to crash due to the bug. --- .../providers/azurerm/resource_arm_local_network_gateway.go | 3 +++ .../providers/azurerm/r/local_network_gateway.html.markdown | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/builtin/providers/azurerm/resource_arm_local_network_gateway.go b/builtin/providers/azurerm/resource_arm_local_network_gateway.go index 6287f0ce2..6038e47c3 100644 --- a/builtin/providers/azurerm/resource_arm_local_network_gateway.go +++ b/builtin/providers/azurerm/resource_arm_local_network_gateway.go @@ -101,6 +101,9 @@ func resourceArmLocalNetworkGatewayRead(d *schema.ResourceData, meta interface{} return err } name := id.Path["localNetworkGateways"] + if name == "" { + return fmt.Errorf("Cannot find parameter 'localNetworkGateways' from '%s'", id.Path) + } resGroup := id.ResourceGroup resp, err := lnetClient.Get(resGroup, name) diff --git a/website/source/docs/providers/azurerm/r/local_network_gateway.html.markdown b/website/source/docs/providers/azurerm/r/local_network_gateway.html.markdown index ac74bafa5..b4681b6e4 100644 --- a/website/source/docs/providers/azurerm/r/local_network_gateway.html.markdown +++ b/website/source/docs/providers/azurerm/r/local_network_gateway.html.markdown @@ -52,5 +52,5 @@ The following attributes are exported: Local Network Gateways can be imported using the `resource id`, e.g. ``` -terraform import azurerm_local_network_gateway.lng1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/microsoft.network/localnetworkgateways/lng1 +terraform import azurerm_local_network_gateway.lng1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Network/localNetworkGateways/lng1 ```