Merge pull request #7624 from hashicorp/import-arm-vnet
provider/azurerm: Support Import of `azurerm_virtual_network`
This commit is contained in:
commit
79d0c22360
|
@ -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"},
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
|
@ -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{
|
||||
|
|
Loading…
Reference in New Issue