Merge pull request #7571 from hashicorp/import-arm-availset
provider/azurerm: Support Import for `azurerm_availability_set`
This commit is contained in:
commit
29c1d36cf4
|
@ -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!
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -16,6 +16,9 @@ func resourceArmAvailabilitySet() *schema.Resource {
|
||||||
Read: resourceArmAvailabilitySetRead,
|
Read: resourceArmAvailabilitySetRead,
|
||||||
Update: resourceArmAvailabilitySetCreate,
|
Update: resourceArmAvailabilitySetCreate,
|
||||||
Delete: resourceArmAvailabilitySetDelete,
|
Delete: resourceArmAvailabilitySetDelete,
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: schema.ImportStatePassthrough,
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"name": {
|
"name": {
|
||||||
|
@ -125,6 +128,8 @@ func resourceArmAvailabilitySetRead(d *schema.ResourceData, meta interface{}) er
|
||||||
availSet := *resp.Properties
|
availSet := *resp.Properties
|
||||||
d.Set("platform_update_domain_count", availSet.PlatformUpdateDomainCount)
|
d.Set("platform_update_domain_count", availSet.PlatformUpdateDomainCount)
|
||||||
d.Set("platform_fault_domain_count", availSet.PlatformFaultDomainCount)
|
d.Set("platform_fault_domain_count", availSet.PlatformFaultDomainCount)
|
||||||
|
d.Set("name", resp.Name)
|
||||||
|
d.Set("location", resp.Location)
|
||||||
|
|
||||||
flattenAndSetTags(d, resp.Tags)
|
flattenAndSetTags(d, resp.Tags)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue