provider/azurerm: Support Import `azurerm_local_network_gateway`

```
% make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMLocalNetworkGateway_'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
TF_ACC=1 go test ./builtin/providers/azurerm -v
-run=TestAccAzureRMLocalNetworkGateway_ -timeout 120m
=== RUN   TestAccAzureRMLocalNetworkGateway_importBasic
--- PASS: TestAccAzureRMLocalNetworkGateway_importBasic (137.98s)
=== RUN   TestAccAzureRMLocalNetworkGateway_basic
--- PASS: TestAccAzureRMLocalNetworkGateway_basic (128.17s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/azurerm
266.169s
```
This commit is contained in:
stack72 2016-07-13 13:14:59 +01:00
parent 9018e073fb
commit bab8032058
No known key found for this signature in database
GPG Key ID: 8619A619B085CB16
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, Read: resourceArmLocalNetworkGatewayRead,
Update: resourceArmLocalNetworkGatewayCreate, Update: resourceArmLocalNetworkGatewayCreate,
Delete: resourceArmLocalNetworkGatewayDelete, Delete: resourceArmLocalNetworkGatewayDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
"name": { "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) 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) d.Set("gateway_address", resp.Properties.GatewayIPAddress)
prefs := []string{} prefs := []string{}