Merge pull request #7626 from hashicorp/import-arm-lng

provider/azurerm: Support Import `azurerm_local_network_gateway`
This commit is contained in:
James Nugent 2016-07-13 09:41:59 -06:00 committed by GitHub
commit 25c786898f
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package azurerm
import (
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMLocalNetworkGateway_importBasic(t *testing.T) {
resourceName := "azurerm_local_network_gateway.test"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMLocalNetworkGatewayDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAzureRMLocalNetworkGatewayConfig_basic,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"resource_group_name"},
//this isn't returned from the API!
},
},
})
}

View File

@ -14,6 +14,9 @@ func resourceArmLocalNetworkGateway() *schema.Resource {
Read: resourceArmLocalNetworkGatewayRead,
Update: resourceArmLocalNetworkGatewayCreate,
Delete: resourceArmLocalNetworkGatewayDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": {
@ -115,6 +118,8 @@ func resourceArmLocalNetworkGatewayRead(d *schema.ResourceData, meta interface{}
return fmt.Errorf("Error reading the state of Azure ARM local network gateway '%s': %s", name, err)
}
d.Set("name", resp.Name)
d.Set("location", resp.Location)
d.Set("gateway_address", resp.Properties.GatewayIPAddress)
prefs := []string{}