diff --git a/outscale/resource_outscale_snapshot_export_task_test.go b/outscale/resource_outscale_snapshot_export_task_test.go index 00a14cf23..172ff4687 100644 --- a/outscale/resource_outscale_snapshot_export_task_test.go +++ b/outscale/resource_outscale_snapshot_export_task_test.go @@ -2,6 +2,7 @@ package outscale import ( "fmt" + "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" @@ -14,6 +15,7 @@ func TestAccOutscaleOAPISnapshotExportTask_basic(t *testing.T) { acctest.RandomWithPrefix("terraform-export-bucket-"), acctest.RandomWithPrefix("terraform-export-bucket-"), } + region := os.Getenv("OUTSCALE_REGION") tags := `tags { key = "test" value = "test" @@ -29,13 +31,13 @@ func TestAccOutscaleOAPISnapshotExportTask_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotExportTaskConfig("", osuBucketNames[0]), + Config: testAccOutscaleOAPISnapshotExportTaskConfig(region, "", osuBucketNames[0]), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISnapshotExportTaskExists("outscale_snapshot_export_task.outscale_snapshot_export_task"), ), }, { - Config: testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketNames[1]), + Config: testAccOutscaleOAPISnapshotExportTaskConfig(region, tags, osuBucketNames[1]), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISnapshotExportTaskExists("outscale_snapshot_export_task.outscale_snapshot_export_task"), ), @@ -59,23 +61,23 @@ func testAccCheckOutscaleOAPISnapshotExportTaskExists(n string) resource.TestChe } } -func testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketName string) string { +func testAccOutscaleOAPISnapshotExportTaskConfig(region, tags, osuBucketName string) string { return fmt.Sprintf(` - resource "outscale_volume" "outscale_volume_snap" { - subregion_name = "eu-west-2a" - size = 10 -} -resource "outscale_snapshot" "outscale_snapshot" { - volume_id = outscale_volume.outscale_volume_snap.volume_id -} -resource "outscale_snapshot_export_task" "outscale_snapshot_export_task" { - snapshot_id = outscale_snapshot.outscale_snapshot.snapshot_id - osu_export { - disk_image_format = "qcow2" - osu_bucket = "%[2]s" - osu_prefix = "new-export" + resource "outscale_volume" "outscale_volume_snap" { + subregion_name = "%[1]sa" + size = 10 } - %[1]s -} - `, tags, osuBucketName) + resource "outscale_snapshot" "outscale_snapshot" { + volume_id = outscale_volume.outscale_volume_snap.volume_id + } + resource "outscale_snapshot_export_task" "outscale_snapshot_export_task" { + snapshot_id = outscale_snapshot.outscale_snapshot.snapshot_id + osu_export { + disk_image_format = "qcow2" + osu_bucket = "%[3]s" + osu_prefix = "new-export" + } + %[2]s + } + `, region, tags, osuBucketName) } diff --git a/outscale/resource_outscale_vm_test.go b/outscale/resource_outscale_vm_test.go index a7fa6520f..874ead8f5 100644 --- a/outscale/resource_outscale_vm_test.go +++ b/outscale/resource_outscale_vm_test.go @@ -186,14 +186,14 @@ func TestAccOutscaleOAPIVM_withNics(t *testing.T) { var server oscgo.Vm omi := os.Getenv("OUTSCALE_IMAGEID") keypair := os.Getenv("OUTSCALE_KEYPAIR") - + region := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, "tinav4.c2r2p2", keypair), + Config: testAccCheckOutscaleOAPIVMConfigBasicWithNics(region, omi, "tinav4.c2r2p2", keypair), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), @@ -695,7 +695,7 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNicAttached(omi, vmType, region, k }`, omi, vmType, region, keypair) } -func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string) string { +func testAccCheckOutscaleOAPIVMConfigBasicWithNics(region, omi, vmType, keypair string) string { return fmt.Sprintf(`resource "outscale_net" "outscale_net" { ip_range = "10.0.0.0/16" } @@ -703,7 +703,7 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string) resource "outscale_subnet" "outscale_subnet" { net_id = outscale_net.outscale_net.net_id ip_range = "10.0.0.0/24" - subregion_name = "eu-west-2a" + subregion_name = "%sa" } resource "outscale_nic" "outscale_nic" { @@ -736,7 +736,7 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string) is_primary = false } } - }`, omi, vmType, keypair) + }`, region, omi, vmType, keypair) } func testAccVmsConfigUpdateOAPIVMTags(omi, vmType string, region, value, keypair, sgId string) string {