Merge pull request #7624 from hashicorp/import-arm-vnet

provider/azurerm: Support Import of `azurerm_virtual_network`
This commit is contained in:
James Nugent 2016-07-13 09:42:32 -06:00 committed by GitHub
commit 79d0c22360
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,34 @@
package azurerm
import (
"fmt"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAzureRMVirtualNetwork_importBasic(t *testing.T) {
resourceName := "azurerm_virtual_network.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMVirtualNetwork_basic, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMVirtualNetworkDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"resource_group_name"},
},
},
})
}

View File

@ -17,6 +17,9 @@ func resourceArmVirtualNetwork() *schema.Resource {
Read: resourceArmVirtualNetworkRead,
Update: resourceArmVirtualNetworkCreate,
Delete: resourceArmVirtualNetworkDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": {
@ -139,6 +142,8 @@ func resourceArmVirtualNetworkRead(d *schema.ResourceData, meta interface{}) err
vnet := *resp.Properties
// update appropriate values
d.Set("name", resp.Name)
d.Set("location", resp.Location)
d.Set("address_space", vnet.AddressSpace.AddressPrefixes)
subnets := &schema.Set{