Skip to content

Commit

Permalink
Merge pull request #7571 from hashicorp/import-arm-availset
Browse files Browse the repository at this point in the history
provider/azurerm: Support Import for `azurerm_availability_set`
  • Loading branch information
jen20 authored Jul 11, 2016
2 parents 4798b13 + f78f043 commit 29c1d36
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
36 changes: 36 additions & 0 deletions builtin/providers/azurerm/import_arm_availability_set_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package azurerm

import (
"testing"

"fmt"

"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)

func TestAccAzureRMAvailabilitySet_importBasic(t *testing.T) {
resourceName := "azurerm_availability_set.test"

ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMVAvailabilitySet_basic, ri, ri)

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMAvailabilitySetDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: config,
},

resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"resource_group_name"},
//this isn't returned from the API!
},
},
})
}
5 changes: 5 additions & 0 deletions builtin/providers/azurerm/resource_arm_availability_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ func resourceArmAvailabilitySet() *schema.Resource {
Read: resourceArmAvailabilitySetRead,
Update: resourceArmAvailabilitySetCreate,
Delete: resourceArmAvailabilitySetDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},

Schema: map[string]*schema.Schema{
"name": {
Expand Down Expand Up @@ -125,6 +128,8 @@ func resourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) er
availSet := *resp.Properties
d.Set("platform_update_domain_count", availSet.PlatformUpdateDomainCount)
d.Set("platform_fault_domain_count", availSet.PlatformFaultDomainCount)
d.Set("name", resp.Name)
d.Set("location", resp.Location)

flattenAndSetTags(d, resp.Tags)

Expand Down

0 comments on commit 29c1d36

Please sign in to comment.