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.
This commit is contained in:
Jay Wang 2017-03-29 11:49:38 -07:00
parent 1c7b8c78ee
commit 630f371b0c
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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
```