Merge pull request #7620 from hashicorp/import-arm-dnszone

provider/azurerm: Support Import for `azurerm_dns_zone`
This commit is contained in:
James Nugent 2016-07-13 09:43:05 -06:00 committed by GitHub
commit ecdc5065bf
2 changed files with 38 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 TestAccAzureRMDnsZone_importBasic(t *testing.T) {
resourceName := "azurerm_dns_zone.test"
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMDnsZone_basic, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMDnsZoneDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"resource_group_name"},
},
},
})
}

View File

@ -14,6 +14,9 @@ func resourceArmDnsZone() *schema.Resource {
Read: resourceArmDnsZoneRead,
Update: resourceArmDnsZoneCreate,
Delete: resourceArmDnsZoneDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"name": &schema.Schema{
@ -110,6 +113,7 @@ func resourceArmDnsZoneRead(d *schema.ResourceData, meta interface{}) error {
d.Set("number_of_record_sets", resp.NumberOfRecordSets)
d.Set("max_number_of_record_sets", resp.MaxNumberOfRecordSets)
d.Set("name", resp.Name)
nameServers := make([]string, 0, len(resp.NameServers))
for _, ns := range resp.NameServers {