-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make huaweicloud_compute_instance_v2 importable (#301)
* Port compute instance v2 importer implementation from openstack * Add missing error handling in resourceComputeInstanceV2ImportState and acceptable tests * Add documentation on importing instances
- Loading branch information
Showing
3 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
huaweicloud/import_huaweicloud_compute_instance_v2_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package huaweicloud | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/helper/resource" | ||
) | ||
|
||
func TestAccComputeV2Instance_importBasic(t *testing.T) { | ||
resourceName := "huaweicloud_compute_instance_v2.instance_1" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckComputeV2InstanceDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccComputeV2Instance_basic, | ||
}, | ||
|
||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{ | ||
"stop_before_destroy", | ||
"force_delete", | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccComputeV2Instance_importbootFromVolumeForceNew_1(t *testing.T) { | ||
resourceName := "huaweicloud_compute_instance_v2.instance_1" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckComputeV2InstanceDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccComputeV2Instance_bootFromVolumeForceNew_1, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{ | ||
"stop_before_destroy", | ||
"force_delete", | ||
}, | ||
}, | ||
}, | ||
}) | ||
} | ||
func TestAccComputeV2Instance_importbootFromVolumeImage(t *testing.T) { | ||
resourceName := "huaweicloud_compute_instance_v2.instance_1" | ||
|
||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckComputeV2InstanceDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccComputeV2Instance_bootFromVolumeImage, | ||
}, | ||
{ | ||
ResourceName: resourceName, | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
ImportStateVerifyIgnore: []string{ | ||
"stop_before_destroy", | ||
"force_delete", | ||
}, | ||
}, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters