provider/azurerm: Support Import of `azurerm_virtual_network`
``` % make testacc TEST=./builtin/providers/azurerm TESTARGS='-run=TestAccAzureRMVirtualNetwork_' ==> 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=TestAccAzureRMVirtualNetwork_ -timeout 120m === RUN TestAccAzureRMVirtualNetwork_importBasic --- PASS: TestAccAzureRMVirtualNetwork_importBasic (129.61s) === RUN TestAccAzureRMVirtualNetwork_basic --- PASS: TestAccAzureRMVirtualNetwork_basic (128.37s) === RUN TestAccAzureRMVirtualNetwork_withTags --- PASS: TestAccAzureRMVirtualNetwork_withTags (151.55s) PASS ok github.com/hashicorp/terraform/builtin/providers/azurerm 409.541s ```
This commit is contained in:
parent
9018e073fb
commit
dc9dc74026
|
@ -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