diff --git a/.github/workflows/others_testacc.yml b/.github/workflows/others_testacc.yml index 4d56bb846..776a82edb 100644 --- a/.github/workflows/others_testacc.yml +++ b/.github/workflows/others_testacc.yml @@ -13,8 +13,8 @@ on: jobs: Others_acceptances_tests: - environment: us-east-2 - runs-on: [self-hosted, linux, us-east-2] + environment: eu-west-2 + runs-on: [self-hosted, linux, eu-west-2] steps: - uses: actions/checkout@v3 with: diff --git a/outscale/data_source_outscale_access_key_test.go b/outscale/data_source_outscale_access_key_test.go index 981ad247a..93537cb5a 100644 --- a/outscale/data_source_outscale_access_key_test.go +++ b/outscale/data_source_outscale_access_key_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleDataSourceAccessKey_basic(t *testing.T) { +func TestAccOthers_DatasourceAccessKey_basic(t *testing.T) { t.Parallel() dataSourceName := "outscale_access_key.outscale_access_key" @@ -28,7 +28,7 @@ func TestAccOutscaleDataSourceAccessKey_basic(t *testing.T) { }) } -func TestAccOutscaleDataSourceAccessKey_withFilters(t *testing.T) { +func TestAccOthers_AccessKey_withFilters(t *testing.T) { t.Parallel() dataSourceName := "outscale_access_key.outscale_access_key" diff --git a/outscale/data_source_outscale_access_keys_test.go b/outscale/data_source_outscale_access_keys_test.go index 170987e65..c4a702cee 100644 --- a/outscale/data_source_outscale_access_keys_test.go +++ b/outscale/data_source_outscale_access_keys_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleDataSourceAccessKeys_basic(t *testing.T) { +func TestAccOthers_DataSourceAccessKeys_basic(t *testing.T) { t.Parallel() dataSourceName := "data.outscale_access_keys.outscale_access_key" @@ -25,7 +25,7 @@ func TestAccOutscaleDataSourceAccessKeys_basic(t *testing.T) { }) } -func TestAccOutscaleDataSourceAccessKeys_withFilters(t *testing.T) { +func TestAccOthers_DataSourceAccessKeys_withFilters(t *testing.T) { t.Parallel() dataSourceName := "data.outscale_access_keys.outscale_access_key" @@ -49,7 +49,7 @@ func testAccClientAccessKeysDataSourceBasic() string { resource "outscale_access_key" "outscale_access_key" {} data "outscale_access_keys" "outscale_access_key" { - access_key_ids = ["${outscale_access_key.outscale_access_key.id}"] + access_key_ids = [outscale_access_key.outscale_access_key.id] } ` } @@ -61,7 +61,7 @@ func testAccClientAccessKeysDataSourceWithFilters() string { data "outscale_access_keys" "outscale_access_key" { filter { name = "access_key_ids" - values = ["${outscale_access_key.outscale_access_key.id}"] + values = [outscale_access_key.outscale_access_key.id] } } ` diff --git a/outscale/data_source_outscale_account_test.go b/outscale/data_source_outscale_account_test.go index c8e00de76..73012b166 100644 --- a/outscale/data_source_outscale_account_test.go +++ b/outscale/data_source_outscale_account_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceAccount_basic(t *testing.T) { +func TestAccOthers_DataSourceAccount_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/outscale/data_source_outscale_accounts_test.go b/outscale/data_source_outscale_accounts_test.go index fb0280344..feb3f973d 100644 --- a/outscale/data_source_outscale_accounts_test.go +++ b/outscale/data_source_outscale_accounts_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceAccounts_basic(t *testing.T) { +func TestAccOthers_DataSourceAccounts_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/outscale/data_source_outscale_api_access_rule_test.go b/outscale/data_source_outscale_api_access_rule_test.go index 31c92ac21..cfc67681b 100644 --- a/outscale/data_source_outscale_api_access_rule_test.go +++ b/outscale/data_source_outscale_api_access_rule_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccDataOutscaleOAPIApiAccessRule_basic(t *testing.T) { +func TestAccOthers_DataOutscaleOAPIApiAccessRule_basic(t *testing.T) { t.Parallel() resourceName := "outscale_api_access_rule.rule_data" @@ -78,7 +78,7 @@ resource "outscale_ca" "ca_rule" { } resource "outscale_api_access_rule" "rule_data" { - ca_ids = ["${outscale_ca.ca_rule.id}"] + ca_ids = [outscale_ca.ca_rule.id] ip_ranges = ["192.4.2.32/16"] description = "test api access rule" } @@ -86,7 +86,7 @@ resource "outscale_api_access_rule" "rule_data" { data "outscale_api_access_rule" "api_access_rule" { filter { name = "api_access_rule_ids" - values = ["${outscale_api_access_rule.rule_data.id}"] + values = [outscale_api_access_rule.rule_data.id] } filter { diff --git a/outscale/data_source_outscale_ca_test.go b/outscale/data_source_outscale_ca_test.go index 96b39a53c..6ddd0f59e 100644 --- a/outscale/data_source_outscale_ca_test.go +++ b/outscale/data_source_outscale_ca_test.go @@ -12,7 +12,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataOutscaleOAPICa_basic(t *testing.T) { +func TestAccOthers_DataOutscaleCa_basic(t *testing.T) { resourceName := "outscale_ca.ca_test" resource.Test(t, resource.TestCase{ @@ -72,16 +72,16 @@ func testAccDataCheckOutscaleCaDestroy(s *terraform.State) error { func testAccDataOutscaleOAPICaConfig(ca_pem string) string { return fmt.Sprintf(` -resource "outscale_ca" "ca_test" { +resource "outscale_ca" "ca_test" { ca_pem = %[1]q description = "Ca testacc create" } data "outscale_ca" "ca_data" { - filter { - name = "ca_ids" - values = ["${outscale_ca.ca_test.id}"] - } + filter { + name = "ca_ids" + values = [outscale_ca.ca_test.id] + } } `, ca_pem) } diff --git a/outscale/data_source_outscale_cas_test.go b/outscale/data_source_outscale_cas_test.go index 316f7f987..2207d1ce2 100644 --- a/outscale/data_source_outscale_cas_test.go +++ b/outscale/data_source_outscale_cas_test.go @@ -12,7 +12,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataOutscaleOAPICas_basic(t *testing.T) { +func TestAccOthers_DataOutscaleCas_basic(t *testing.T) { resName := "outscale_ca.ca_test" resource.Test(t, resource.TestCase{ @@ -72,17 +72,25 @@ func testAccDataCheckOutscaleCasDestroy(s *terraform.State) error { func testAccDataOutscaleOAPICasConfig(ca_pem string) string { return fmt.Sprintf(` -resource "outscale_ca" "ca_test" { +resource "outscale_ca" "ca_test" { ca_pem = %[1]q description = "Ca testacc create" } -data "outscale_cas" "cas_data" { - filter { - name = "ca_ids" - values = ["${outscale_ca.ca_test.id}"] - } +resource "outscale_ca" "ca_test2" { + ca_pem = %[1]q + description = "Ca testacc create2" +} + +data "outscale_cas" "cas_data" { + filter { + name = "ca_ids" + values = [outscale_ca.ca_test.id] + } + filter { + name = "description" + values = ["Ca testacc create2"] + } } -data "outscale_cas" "all_cas" {} `, ca_pem) } diff --git a/outscale/data_source_outscale_client_gateway_test.go b/outscale/data_source_outscale_client_gateway_test.go index c4801504f..a27a1c913 100644 --- a/outscale/data_source_outscale_client_gateway_test.go +++ b/outscale/data_source_outscale_client_gateway_test.go @@ -9,7 +9,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleGatewayDatasource_basic(t *testing.T) { +func TestAccOthers_GatewayDatasource_basic(t *testing.T) { t.Parallel() rBgpAsn := utils.RandIntRange(64512, 65534) value := fmt.Sprintf("testacc-%s", acctest.RandString(5)) @@ -25,7 +25,7 @@ func TestAccOutscaleGatewayDatasource_basic(t *testing.T) { }) } -func TestAccOutscaleGatewayDatasource_withFilters(t *testing.T) { +func TestAccOthers_GatewayDatasource_withFilters(t *testing.T) { t.Parallel() // datasourceName := "data.outscale_client_gateway.test" rBgpAsn := utils.RandIntRange(64512, 65534) @@ -42,7 +42,7 @@ func TestAccOutscaleGatewayDatasource_withFilters(t *testing.T) { }) } -func TestAccOutscaleGatewayDatasource_withFiltersNoLocalhost(t *testing.T) { +func TestAccOthers_GatewayDatasource_withFiltersNoLocalhost(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -69,7 +69,7 @@ func testAccClientGatewayDatasourceBasic(rBgpAsn int, value string) string { } data "outscale_client_gateway" "test" { - client_gateway_id = "${outscale_client_gateway.foo.id}" + client_gateway_id = outscale_client_gateway.foo.id } `, rBgpAsn, value) } @@ -90,7 +90,7 @@ func testAccClientGatewayDatasourceWithFilters(rBgpAsn int, value string) string data "outscale_client_gateway" "test" { filter { name = "client_gateway_ids" - values = ["${outscale_client_gateway.foo.id}"] + values = [outscale_client_gateway.foo.id] } } `, rBgpAsn, value) diff --git a/outscale/data_source_outscale_client_gateways_test.go b/outscale/data_source_outscale_client_gateways_test.go index 59175acb2..dd8c6767c 100644 --- a/outscale/data_source_outscale_client_gateways_test.go +++ b/outscale/data_source_outscale_client_gateways_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleClientGatewaysDatasource_basic(t *testing.T) { +func TestAccOthers_ClientGatewaysDatasource_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -18,7 +18,7 @@ func TestAccOutscaleClientGatewaysDatasource_basic(t *testing.T) { }) } -func TestAccOutscaleClientGatewaysDatasource_withFilters(t *testing.T) { +func TestAccOthers_ClientGatewaysDatasource_withFilters(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -49,7 +49,7 @@ const testAccOutscaleClientGatewaysDatasourceConfigBasic = ` } data "outscale_client_gateways" "test" { - client_gateway_ids = ["${outscale_client_gateway.foo1.id}", "${outscale_client_gateway.foo2.id}"] + client_gateway_ids = [outscale_client_gateway.foo1.id, outscale_client_gateway.foo2.id] } ` @@ -74,7 +74,7 @@ const testAccOutscaleClientGatewaysDatasourceConfigWithFilters = ` data "outscale_client_gateways" "test" { filter { name = "client_gateway_ids" - values = ["${outscale_client_gateway.foo1.id}", "${outscale_client_gateway.foo2.id}"] + values = [outscale_client_gateway.foo1.id, outscale_client_gateway.foo2.id] } } ` diff --git a/outscale/data_source_outscale_dhcp_option_test.go b/outscale/data_source_outscale_dhcp_option_test.go index 996de273c..afbe10093 100644 --- a/outscale/data_source_outscale_dhcp_option_test.go +++ b/outscale/data_source_outscale_dhcp_option_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleDHCPOption_basic(t *testing.T) { +func TestAccOthers_DHCPOption_basic(t *testing.T) { t.Parallel() resourceName := "outscale_dhcp_option.foo" dataSourceName := "data.outscale_dhcp_option.test" @@ -45,7 +45,7 @@ func TestAccOutscaleDHCPOption_basic(t *testing.T) { }) } -func TestAccOutscaleDHCPOption_withFilters(t *testing.T) { +func TestAccOthers_DHCPOption_withFilters(t *testing.T) { t.Parallel() resourceName := "outscale_dhcp_option.foo" dataSourceName := "data.outscale_dhcp_option.test" diff --git a/outscale/data_source_outscale_dhcp_options_test.go b/outscale/data_source_outscale_dhcp_options_test.go index c90d9022c..2e64abd4c 100644 --- a/outscale/data_source_outscale_dhcp_options_test.go +++ b/outscale/data_source_outscale_dhcp_options_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleDHCPOptionsDatasource_basic(t *testing.T) { +func TestAccOthers_DHCPOptionsDatasource_basic(t *testing.T) { t.Parallel() value := fmt.Sprintf("test-acc-value-%s", acctest.RandString(5)) @@ -23,7 +23,7 @@ func TestAccOutscaleDHCPOptionsDatasource_basic(t *testing.T) { }) } -func TestAccOutscaleDHCPOptionsDatasource_withFilters(t *testing.T) { +func TestAccOthers_DHCPOptionsDatasource_withFilters(t *testing.T) { t.Parallel() value := fmt.Sprintf("test-acc-value-%s", acctest.RandString(5)) diff --git a/outscale/data_source_outscale_flexible_gpu_catalog_test.go b/outscale/data_source_outscale_flexible_gpu_catalog_test.go index bd6a138ee..4faabcea3 100644 --- a/outscale/data_source_outscale_flexible_gpu_catalog_test.go +++ b/outscale/data_source_outscale_flexible_gpu_catalog_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIFlexibleGpuCatalog_basic(t *testing.T) { +func TestAccOthers_DataSourceFlexibleGpuCatalog_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/outscale/data_source_outscale_flexible_gpu_test.go b/outscale/data_source_outscale_flexible_gpu_test.go index 9ed6ee97d..5a1d781bb 100644 --- a/outscale/data_source_outscale_flexible_gpu_test.go +++ b/outscale/data_source_outscale_flexible_gpu_test.go @@ -2,15 +2,13 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPIFlexibleGpu_basic(t *testing.T) { - t.Parallel() - region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION")) +func TestAccOthers_DataSourceFlexibleGpu_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,25 +17,25 @@ func TestAccDataSourceOutscaleOAPIFlexibleGpu_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region, region), + Config: testAccDataSourceOutscaleOAPIFlexibleGpuConfig(utils.GetRegion()), }, }, }) } -func testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region, region1 string) string { +func testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region string) string { return fmt.Sprintf(` - resource "outscale_flexible_gpu" "fGPU-data1" { + resource "outscale_flexible_gpu" "dataGPU" { model_name = "nvidia-p6" generation = "v5" - subregion_name = "%s" + subregion_name = "%sa" delete_on_vm_deletion = true } - data "outscale_flexible_gpu" "data_fGPU-1" { + data "outscale_flexible_gpu" "data_fGPU" { filter { name = "flexible_gpu_ids" - values = [outscale_flexible_gpu.fGPU-data1.flexible_gpu_id] + values = [outscale_flexible_gpu.dataGPU.flexible_gpu_id] } filter { name = "delete_on_vm_deletion" @@ -57,8 +55,8 @@ func testAccDataSourceOutscaleOAPIFlexibleGpuConfig(region, region1 string) stri } filter { name = "subregion_names" - values = ["%s"] + values = ["%[1]sa"] } } - `, region, region) + `, region) } diff --git a/outscale/data_source_outscale_flexible_gpus_test.go b/outscale/data_source_outscale_flexible_gpus_test.go index 9cd09dcc6..6ca38ae18 100644 --- a/outscale/data_source_outscale_flexible_gpus_test.go +++ b/outscale/data_source_outscale_flexible_gpus_test.go @@ -2,15 +2,13 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPIFlexibleGpus_basic(t *testing.T) { - t.Parallel() - region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION")) +func TestAccOthers_DataSourceFlexibleGpus_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,18 +17,18 @@ func TestAccDataSourceOutscaleOAPIFlexibleGpus_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region, region), + Config: testAccDataSourceOutscaleOAPIFlexibleGpusConfig(utils.GetRegion()), }, }, }) } -func testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region, region1 string) string { +func testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region string) string { return fmt.Sprintf(` - resource "outscale_flexible_gpu" "fGPUS-1" { + resource "outscale_flexible_gpu" "fGPUS-1" { model_name = "nvidia-p6" generation = "v5" - subregion_name = "%s" + subregion_name = "%sa" delete_on_vm_deletion = true } @@ -57,8 +55,8 @@ func testAccDataSourceOutscaleOAPIFlexibleGpusConfig(region, region1 string) str } filter { name = "subregion_names" - values = ["%s"] + values = ["%[1]sa"] } } - `, region, region) + `, region) } diff --git a/outscale/data_source_outscale_image_export_task_test.go b/outscale/data_source_outscale_image_export_task_test.go index 2c56b61fc..68d46f354 100644 --- a/outscale/data_source_outscale_image_export_task_test.go +++ b/outscale/data_source_outscale_image_export_task_test.go @@ -7,13 +7,14 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPIImageExportTaskDataSource_basic(t *testing.T) { +func TestAccVM_withImageExportTaskDataSource_basic(t *testing.T) { + t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") imageName := acctest.RandomWithPrefix("test-image-name") if os.Getenv("TEST_QUOTA") == "true" { @@ -24,7 +25,7 @@ func TestAccOutscaleOAPIImageExportTaskDataSource_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, "tinav4.c2r2p2", region, imageName), + Config: testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleImageExportTaskDataSourceID("data.outscale_image_export_task.test"), ), @@ -53,7 +54,7 @@ func testAccCheckOutscaleImageExportTaskDataSourceID(n string) resource.TestChec func testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, vmType, region, imageName string) string { return fmt.Sprintf(` - resource "outscale_vm" "basic" { + resource "outscale_vm" "basicExport" { image_id = "%s" vm_type = "%s" keypair_name = "terraform-basic" @@ -62,7 +63,7 @@ func testAccOutscaleOAPIImageExportTaskDataSourceConfig(omi, vmType, region, ima resource "outscale_image" "foo" { image_name = "%s" - vm_id = outscale_vm.basic.id + vm_id = outscale_vm.basicExport.id no_reboot = "true" description = "terraform testing" } diff --git a/outscale/data_source_outscale_image_export_tasks_test.go b/outscale/data_source_outscale_image_export_tasks_test.go index baee706e0..b594eeb33 100644 --- a/outscale/data_source_outscale_image_export_tasks_test.go +++ b/outscale/data_source_outscale_image_export_tasks_test.go @@ -6,13 +6,14 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPIImageExportTasksDataSource_basic(t *testing.T) { +func TestAccVM_withImageExportTasksDataSource_basic(t *testing.T) { + t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") imageName := acctest.RandomWithPrefix("test-image-name") if os.Getenv("TEST_QUOTA") == "true" { @@ -23,7 +24,7 @@ func TestAccOutscaleOAPIImageExportTasksDataSource_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIImageExportTasksDataSourceConfig(omi, "tinav4.c2r2p2", region, imageName), + Config: testAccOutscaleOAPIImageExportTasksDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleImageExportTaskDataSourceID("outscale_image_export_task.outscale_image_export_task"), ), diff --git a/outscale/data_source_outscale_image_test.go b/outscale/data_source_outscale_image_test.go index 6d14b2437..66915851c 100644 --- a/outscale/data_source_outscale_image_test.go +++ b/outscale/data_source_outscale_image_test.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIImageDataSource_Instance(t *testing.T) { +func TestAccVM_WithImageDataSource_basic(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") imageName := fmt.Sprintf("image-test-%d", acctest.RandInt()) resource.Test(t, resource.TestCase{ @@ -23,30 +23,7 @@ func TestAccOutscaleOAPIImageDataSource_Instance(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIImageConfigBasic(omi, "tinav4.c2r2p2", region, imageName), - Check: resource.ComposeTestCheckFunc( - testAccCheckOutscaleOAPIImageDataSourceID("data.outscale_image.nat_ami"), - resource.TestCheckResourceAttr("data.outscale_image.nat_ami", "architecture", "x86_64"), - ), - }, - }, - }) -} - -func TestAccOutscaleOAPIImageDataSource_basic(t *testing.T) { - t.Parallel() - omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") - imageName := fmt.Sprintf("image-test-%d", acctest.RandInt()) - - resource.Test(t, resource.TestCase{ - PreCheck: func() { - testAccPreCheck(t) - }, - Providers: testAccProviders, - Steps: []resource.TestStep{ - { - Config: testAccCheckOutscaleOAPIImageDataSourceBasicConfig(omi, "tinav4.c2r2p2", region, imageName), + Config: testAccCheckOutscaleOAPIImageDataSourceBasicConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIImageDataSourceID("data.outscale_image.omi"), ), @@ -72,7 +49,7 @@ func testAccCheckOutscaleOAPIImageDataSourceID(n string) resource.TestCheckFunc func testAccCheckOutscaleOAPIImageDataSourceBasicConfig(omi, vmType, region, imageName string) string { return fmt.Sprintf(` - resource "outscale_vm" "basic" { + resource "outscale_vm" "basicIm" { image_id = "%[1]s" vm_type = "%[2]s" keypair_name = "terraform-basic" @@ -81,34 +58,14 @@ func testAccCheckOutscaleOAPIImageDataSourceBasicConfig(omi, vmType, region, ima resource "outscale_image" "image" { image_name = "%[4]s" - vm_id = "${outscale_vm.basic.id}" + vm_id = outscale_vm.basicIm.id } data "outscale_image" "omi" { filter { name = "image_ids" - values = ["${outscale_image.image.id}"] + values = [outscale_image.image.id] } } `, omi, vmType, region, imageName) } - -func testAccCheckOutscaleOAPIImageConfigBasic(omi, vmType, region, imageName string) string { - return fmt.Sprintf(` - resource "outscale_vm" "basic" { - image_id = "%[1]s" - vm_type = "%[2]s" - keypair_name = "terraform-basic" - placement_subregion_name = "%[3]sa" - } - - resource "outscale_image" "foo" { - image_name = "%[4]s" - vm_id = "${outscale_vm.basic.id}" - } - - data "outscale_image" "nat_ami" { - image_id = "${outscale_image.foo.id}" - } - `, omi, vmType, region, imageName) -} diff --git a/outscale/data_source_outscale_images_test.go b/outscale/data_source_outscale_images_test.go index ef9fb081f..ebcd9580c 100644 --- a/outscale/data_source_outscale_images_test.go +++ b/outscale/data_source_outscale_images_test.go @@ -8,12 +8,12 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIImagesDataSource_Instance(t *testing.T) { +func TestAccVM_WithImagesDataSource_basic(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") imageName := fmt.Sprintf("image-test-%d", acctest.RandInt()) resource.Test(t, resource.TestCase{ @@ -23,7 +23,7 @@ func TestAccOutscaleOAPIImagesDataSource_Instance(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIImagesDataSourceConfig(omi, "tinav4.c2r2p2", region, imageName), + Config: testAccCheckOutscaleOAPIImagesDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIImagesDataSourceID("data.outscale_images.nat_ami"), ), @@ -65,18 +65,18 @@ func testAccCheckOutscaleOAPIImagesDataSourceConfig(omi, vmType, region, imageNa resource "outscale_image" "image_one" { image_name = "%[4]s-one" - vm_id = "${outscale_vm.basic_one.id}" + vm_id = outscale_vm.basic_one.id } resource "outscale_image" "image_two" { image_name = "%[4]s-two" - vm_id = "${outscale_vm.basic_two.id}" + vm_id = outscale_vm.basic_two.id } data "outscale_images" "nat_ami" { filter { name = "image_ids" - values = ["${outscale_image.image_one.id}", "${outscale_image.image_two.id}"] + values = [outscale_image.image_one.id, outscale_image.image_two.id] } } `, omi, vmType, region, imageName) diff --git a/outscale/data_source_outscale_internet_service_test.go b/outscale/data_source_outscale_internet_service_test.go index e06aa905b..478080916 100644 --- a/outscale/data_source_outscale_internet_service_test.go +++ b/outscale/data_source_outscale_internet_service_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPIInternetServiceDatasource_basic(t *testing.T) { +func TestAccOthers_InternetServiceDatasource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -28,7 +28,7 @@ const testAccOutscaleOAPIInternetServiceDatasourceConfig = ` data "outscale_internet_service" "outscale_internet_serviced" { filter { name = "internet_service_ids" - values = ["${outscale_internet_service.outscale_internet_service.internet_service_id}"] + values = [outscale_internet_service.outscale_internet_service.internet_service_id] } } ` diff --git a/outscale/data_source_outscale_internet_services_test.go b/outscale/data_source_outscale_internet_services_test.go index 0f77a91cf..1a554f02f 100644 --- a/outscale/data_source_outscale_internet_services_test.go +++ b/outscale/data_source_outscale_internet_services_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPIInternetServicesDatasource_basic(t *testing.T) { +func TestAccOthers_InternetServicesDatasource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -25,7 +25,7 @@ const testAccOutscaleOAPIInternetServicesDatasourceConfig = ` data "outscale_internet_services" "outscale_internet_services" { filter { name = "internet_service_id" - values = ["${outscale_internet_service.gateway.id}"] + values = [outscale_internet_service.gateway.id] } } ` diff --git a/outscale/data_source_outscale_keypair_test.go b/outscale/data_source_outscale_keypair_test.go index 73bec91e6..db2c10ff0 100644 --- a/outscale/data_source_outscale_keypair_test.go +++ b/outscale/data_source_outscale_keypair_test.go @@ -9,7 +9,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIKeypairDataSource_Instance(t *testing.T) { +func TestAccOthers_KeypairDataSource_Instance(t *testing.T) { t.Parallel() keyPairName := fmt.Sprintf("acc-test-keypair-%d", utils.RandIntRange(0, 400)) @@ -50,10 +50,9 @@ func testAccCheckOutscaleOAPIKeypairDataSourceConfig(keypairName string) string } data "outscale_keypair" "nat_ami" { - #keypair_name = "${outscale_keypair.a_key_pair.id}" filter { name = "keypair_names" - values = ["${outscale_keypair.a_key_pair.keypair_name}"] + values = [outscale_keypair.a_key_pair.keypair_name] } } `, keypairName) diff --git a/outscale/data_source_outscale_keypairs_test.go b/outscale/data_source_outscale_keypairs_test.go index 4a9c7c385..5ff462e8c 100644 --- a/outscale/data_source_outscale_keypairs_test.go +++ b/outscale/data_source_outscale_keypairs_test.go @@ -9,7 +9,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIKeypairsDataSource_Instance(t *testing.T) { +func TestAccOthers_KeypairsDataSource_Instance(t *testing.T) { t.Parallel() keyPairName := fmt.Sprintf("testacc-keypair-%d", utils.RandIntRange(0, 400)) resource.Test(t, resource.TestCase{ diff --git a/outscale/data_source_outscale_load_balancer_tags_test.go b/outscale/data_source_outscale_load_balancer_tags_test.go index a80544afb..7b44ef61a 100644 --- a/outscale/data_source_outscale_load_balancer_tags_test.go +++ b/outscale/data_source_outscale_load_balancer_tags_test.go @@ -2,19 +2,17 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) func TestAccOutscaleOAPIDSLoadBalancerTags_basic(t *testing.T) { t.Parallel() r := acctest.RandString(4) - region := os.Getenv("OUTSCALE_REGION") - zone := fmt.Sprintf("%sa", region) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -23,7 +21,7 @@ func TestAccOutscaleOAPIDSLoadBalancerTags_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: getTestAccDSODSutscaleOAPILBUDSTagsConfig(r, zone), + Config: getTestAccDSODSutscaleOAPILBUDSTagsConfig(r, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckODSutscaleOAPILBUDSTagsExists("data.outscale_load_balancer_tags.testds"), resource.TestCheckResourceAttr( @@ -51,7 +49,7 @@ func testAccCheckODSutscaleOAPILBUDSTagsExists(n string) resource.TestCheckFunc func getTestAccDSODSutscaleOAPILBUDSTagsConfig(r string, zone string) string { return fmt.Sprintf(` resource "outscale_load_balancer" "bar" { - subregion_names = ["%s"] + subregion_names = ["%sa"] load_balancer_name = "foobar-terraform-elb-%s" listeners { diff --git a/outscale/data_source_outscale_load_balancer_test.go b/outscale/data_source_outscale_load_balancer_test.go index 73b5c7d9c..12b70637c 100644 --- a/outscale/data_source_outscale_load_balancer_test.go +++ b/outscale/data_source_outscale_load_balancer_test.go @@ -2,20 +2,19 @@ package outscale import ( "fmt" - "os" "testing" oscgo "github.com/outscale/osc-sdk-go/v2" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPIDSLBU_basic(t *testing.T) { +func TestAccOthers_LBU_basic(t *testing.T) { t.Parallel() var conf oscgo.LoadBalancer - region := os.Getenv("OUTSCALE_REGION") - zone := fmt.Sprintf("%sa", region) + zone := fmt.Sprintf("%sa", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) diff --git a/outscale/data_source_outscale_load_balancers_test.go b/outscale/data_source_outscale_load_balancers_test.go index 958eeafdc..5eea5fc5d 100644 --- a/outscale/data_source_outscale_load_balancers_test.go +++ b/outscale/data_source_outscale_load_balancers_test.go @@ -2,17 +2,15 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) { +func TestAccOthers_LBUs_basic(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") - zone := fmt.Sprintf("%sa", region) + region := fmt.Sprintf("%sa", utils.GetRegion()) numLbu := utils.RandIntRange(0, 50) resource.Test(t, resource.TestCase{ @@ -24,7 +22,7 @@ func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPILBUDestroy, Steps: []resource.TestStep{ { - Config: testAccDSOutscaleOAPILBsUConfig(zone, numLbu), + Config: testAccDSOutscaleOAPILBsUConfig(region, numLbu), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.outscale_load_balancers.test", "load_balancer.#", "1"), )}, @@ -32,7 +30,7 @@ func TestAccOutscaleOAPIDSLBSU_basic(t *testing.T) { }) } -func testAccDSOutscaleOAPILBsUConfig(zone string, numLbu int) string { +func testAccDSOutscaleOAPILBsUConfig(region string, numLbu int) string { return fmt.Sprintf(` resource "outscale_load_balancer" "bar" { subregion_names = ["%s"] @@ -56,5 +54,5 @@ func testAccDSOutscaleOAPILBsUConfig(zone string, numLbu int) string { data "outscale_load_balancers" "test" { load_balancer_name = [outscale_load_balancer.bar.id] } -`, zone, numLbu) +`, region, numLbu) } diff --git a/outscale/data_source_outscale_nat_service_test.go b/outscale/data_source_outscale_nat_service_test.go index f07f24add..3fd1d0e8b 100644 --- a/outscale/data_source_outscale_nat_service_test.go +++ b/outscale/data_source_outscale_nat_service_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPINatServiceDataSource_Instance(t *testing.T) { +func TestAccNet_WithNatServiceDataSource_Instance(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -50,7 +50,7 @@ const testAccCheckOutscaleOAPINatServiceDataSourceConfig = ` } resource "outscale_subnet" "outscale_subnet" { - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id ip_range = "10.0.0.0/18" } @@ -58,33 +58,33 @@ const testAccCheckOutscaleOAPINatServiceDataSourceConfig = ` resource "outscale_nat_service" "outscale_nat_service" { depends_on = ["outscale_route.outscale_route"] - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" - public_ip_id = "${outscale_public_ip.outscale_public_ip.public_ip_id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id + public_ip_id = outscale_public_ip.outscale_public_ip.public_ip_id } resource "outscale_route_table" "outscale_route_table" { - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id } resource "outscale_route" "outscale_route" { destination_ip_range = "0.0.0.0/0" - gateway_id = "${outscale_internet_service.outscale_internet_service.internet_service_id}" - route_table_id = "${outscale_route_table.outscale_route_table.route_table_id}" + gateway_id = outscale_internet_service.outscale_internet_service.internet_service_id + route_table_id = outscale_route_table.outscale_route_table.route_table_id } resource "outscale_route_table_link" "outscale_route_table_link" { - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" - route_table_id = "${outscale_route_table.outscale_route_table.id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id + route_table_id = outscale_route_table.outscale_route_table.id } resource "outscale_internet_service" "outscale_internet_service" {} resource "outscale_internet_service_link" "outscale_internet_service_link" { - net_id = "${outscale_net.outscale_net.net_id}" - internet_service_id = "${outscale_internet_service.outscale_internet_service.id}" + net_id = outscale_net.outscale_net.net_id + internet_service_id = outscale_internet_service.outscale_internet_service.id } data "outscale_nat_service" "nat" { - nat_service_id = "${outscale_nat_service.outscale_nat_service.id}" + nat_service_id = outscale_nat_service.outscale_nat_service.id } ` diff --git a/outscale/data_source_outscale_nat_services_test.go b/outscale/data_source_outscale_nat_services_test.go index b14a6813b..c66181515 100644 --- a/outscale/data_source_outscale_nat_services_test.go +++ b/outscale/data_source_outscale_nat_services_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPINatServicesDataSource_Instance(t *testing.T) { +func TestAccNet_WithNatServicesDataSource_Instance(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -35,7 +35,7 @@ const testAccCheckOutscaleOAPINatServicesDataSourceConfig = ` } resource "outscale_subnet" "outscale_subnet" { - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id ip_range = "10.0.0.0/18" } @@ -43,12 +43,12 @@ const testAccCheckOutscaleOAPINatServicesDataSourceConfig = ` resource "outscale_nat_service" "outscale_nat_service" { depends_on = ["outscale_route.outscale_route"] - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" - public_ip_id = "${outscale_public_ip.outscale_public_ip.public_ip_id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id + public_ip_id = outscale_public_ip.outscale_public_ip.public_ip_id } resource "outscale_route_table" "outscale_route_table" { - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id } resource "outscale_route" "outscale_route" { diff --git a/outscale/data_source_outscale_net_access_point_services_test.go b/outscale/data_source_outscale_net_access_point_services_test.go index a98790727..b3dc5da5b 100644 --- a/outscale/data_source_outscale_net_access_point_services_test.go +++ b/outscale/data_source_outscale_net_access_point_services_test.go @@ -2,15 +2,15 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPINetAccessPointServices_basic(t *testing.T) { +func TestAccNet_AccessPointServicesDataSource_basic(t *testing.T) { t.Parallel() - serviceName := fmt.Sprintf("com.outscale.%s.api", os.Getenv("OUTSCALE_REGION")) + serviceName := fmt.Sprintf("com.outscale.%s.api", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,13 +19,13 @@ func TestAccDataSourceOutscaleOAPINetAccessPointServices_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPINetAccessPointServicesConfig(serviceName, serviceName), + Config: testAccDataSourceOutscaleOAPINetAccessPointServicesConfig(serviceName), }, }, }) } -func testAccDataSourceOutscaleOAPINetAccessPointServicesConfig(sName, sName2 string) string { +func testAccDataSourceOutscaleOAPINetAccessPointServicesConfig(sName string) string { return fmt.Sprintf(` resource "outscale_net" "outscale_net" { ip_range = "10.0.0.0/16" @@ -38,7 +38,7 @@ func testAccDataSourceOutscaleOAPINetAccessPointServicesConfig(sName, sName2 str resource "outscale_net_access_point" "net_access_point_1" { net_id = outscale_net.outscale_net.net_id route_table_ids = [outscale_route_table.route_table-1.route_table_id] - service_name = "%s" + service_name = "%[1]s" tags { key = "name" value = "terraform-Net-Access-Point" @@ -49,11 +49,11 @@ func testAccDataSourceOutscaleOAPINetAccessPointServicesConfig(sName, sName2 str data "outscale_net_access_point_services" "all-services" { filter { name = "service_names" - values = [ "%s"] + values = [ "%[1]s"] } } data "outscale_net_access_point_services" "all-services2" { } - `, sName, sName2) + `, sName) } diff --git a/outscale/data_source_outscale_net_access_point_test.go b/outscale/data_source_outscale_net_access_point_test.go index 94e64510d..13511ac2a 100644 --- a/outscale/data_source_outscale_net_access_point_test.go +++ b/outscale/data_source_outscale_net_access_point_test.go @@ -2,15 +2,15 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPINetAccessPoint_basic(t *testing.T) { +func TestAccNet_AccessPointDataSource_basic(t *testing.T) { t.Parallel() - serviceName := fmt.Sprintf("com.outscale.%s.api", os.Getenv("OUTSCALE_REGION")) + serviceName := fmt.Sprintf("com.outscale.%s.api", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,13 +19,13 @@ func TestAccDataSourceOutscaleOAPINetAccessPoint_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPINetAccessPointConfig(serviceName, serviceName), + Config: testAccDataSourceOutscaleOAPINetAccessPointConfig(serviceName), }, }, }) } -func testAccDataSourceOutscaleOAPINetAccessPointConfig(sName, sName2 string) string { +func testAccDataSourceOutscaleOAPINetAccessPointConfig(sName string) string { return fmt.Sprintf(` resource "outscale_net" "outscale_net" { ip_range = "10.0.0.0/16" @@ -38,7 +38,7 @@ func testAccDataSourceOutscaleOAPINetAccessPointConfig(sName, sName2 string) str resource "outscale_net_access_point" "net_access_point_1" { net_id = outscale_net.outscale_net.net_id route_table_ids = [outscale_route_table.route_table-1.route_table_id] - service_name = "%s" + service_name = "%[1]s" tags { key = "name" value = "terraform-Net-Access-Point" @@ -57,7 +57,7 @@ func testAccDataSourceOutscaleOAPINetAccessPointConfig(sName, sName2 string) str } filter { name = "service_names" - values = [ "%s"] + values = [ "%[1]s"] } filter { name = "states" @@ -73,5 +73,5 @@ func testAccDataSourceOutscaleOAPINetAccessPointConfig(sName, sName2 string) str } } - `, sName, sName2) + `, sName) } diff --git a/outscale/data_source_outscale_net_access_points_test.go b/outscale/data_source_outscale_net_access_points_test.go index 71e166f3c..8807c42c4 100644 --- a/outscale/data_source_outscale_net_access_points_test.go +++ b/outscale/data_source_outscale_net_access_points_test.go @@ -2,15 +2,15 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPINetAccessPoints_basic(t *testing.T) { +func TestAccNet_AccessPointsDataSource_basic(t *testing.T) { t.Parallel() - serviceName := fmt.Sprintf("com.outscale.%s.api", os.Getenv("OUTSCALE_REGION")) + serviceName := fmt.Sprintf("com.outscale.%s.api", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,13 +19,13 @@ func TestAccDataSourceOutscaleOAPINetAccessPoints_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPINetAccessPointsConfig(serviceName, serviceName), + Config: testAccDataSourceOutscaleOAPINetAccessPointsConfig(serviceName), }, }, }) } -func testAccDataSourceOutscaleOAPINetAccessPointsConfig(sName, sName2 string) string { +func testAccDataSourceOutscaleOAPINetAccessPointsConfig(sName string) string { return fmt.Sprintf(` resource "outscale_net" "outscale_net" { ip_range = "10.0.0.0/16" @@ -38,7 +38,7 @@ func testAccDataSourceOutscaleOAPINetAccessPointsConfig(sName, sName2 string) st resource "outscale_net_access_point" "net_access_point_1" { net_id = outscale_net.outscale_net.net_id route_table_ids = [outscale_route_table.route_table-1.route_table_id] - service_name = "%s" + service_name = "%[1]s" tags { key = "name" value = "terraform-Net-Access-Point" @@ -57,7 +57,7 @@ func testAccDataSourceOutscaleOAPINetAccessPointsConfig(sName, sName2 string) st } filter { name = "service_names" - values = [ "%s"] + values = [ "%[1]s"] } filter { name = "states" @@ -73,5 +73,5 @@ func testAccDataSourceOutscaleOAPINetAccessPointsConfig(sName, sName2 string) st } } - `, sName, sName2) + `, sName) } diff --git a/outscale/data_source_outscale_net_attributes_test.go b/outscale/data_source_outscale_net_attributes_test.go index db3204bf6..dc3266fcb 100644 --- a/outscale/data_source_outscale_net_attributes_test.go +++ b/outscale/data_source_outscale_net_attributes_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIDSLinAttr_basic(t *testing.T) { +func TestAccNet_AttributesDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -58,14 +58,12 @@ const testAccOutscaleOAPIDSLinAttrConfig = ` } } - - resource "outscale_net_attributes" "outscale_net_attributes" { - net_id = "${outscale_net.vpc.id}" + net_id = outscale_net.vpc.id dhcp_options_set_id = outscale_net.vpc2.dhcp_options_set_id } data "outscale_net_attributes" "test" { - net_id = "${outscale_net.vpc.id}" + net_id = outscale_net.vpc.id } ` diff --git a/outscale/data_source_outscale_net_peering_test.go b/outscale/data_source_outscale_net_peering_test.go index 76388baeb..3c4904807 100644 --- a/outscale/data_source_outscale_net_peering_test.go +++ b/outscale/data_source_outscale_net_peering_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccDataSourceOutscaleOAPILinPeeringConnection_basic(t *testing.T) { +func TestAccNet_PeeringConnectionDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -68,14 +68,14 @@ const testAccDataSourceOutscaleOAPILinPeeringConnectionConfig = ` } resource "outscale_net_peering" "net_peering" { - accepter_net_id = "${outscale_net.net.net_id}" - source_net_id = "${outscale_net.net2.net_id}" + accepter_net_id = outscale_net.net.net_id + source_net_id = outscale_net.net2.net_id } data "outscale_net_peering" "net_peering_data" { filter { name = "net_peering_ids" - values = ["${outscale_net_peering.net_peering.net_peering_id}"] + values = [outscale_net_peering.net_peering.net_peering_id] } } ` diff --git a/outscale/data_source_outscale_net_peerings_test.go b/outscale/data_source_outscale_net_peerings_test.go index a01e34f98..0717473ce 100644 --- a/outscale/data_source_outscale_net_peerings_test.go +++ b/outscale/data_source_outscale_net_peerings_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPILinPeeringsConnection_basic(t *testing.T) { +func TestAccNet_PeeringsConnectionDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/data_source_outscale_net_test.go b/outscale/data_source_outscale_net_test.go index 5273083fb..e0c87da79 100644 --- a/outscale/data_source_outscale_net_test.go +++ b/outscale/data_source_outscale_net_test.go @@ -11,7 +11,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPIVpc_basic(t *testing.T) { +func TestAccNet_DataSource_basic(t *testing.T) { t.Parallel() rand.Seed(time.Now().UTC().UnixNano()) ipRange := utils.RandVpcCidr() @@ -74,7 +74,7 @@ func testAccDataSourceOutscaleOAPIVpcConfig(ipRange, tag string) string { data "outscale_net" "by_id" { filter { name = "net_ids" - values = ["${outscale_net.test.id}"] + values = [outscale_net.test.id] } } `, ipRange, tag) diff --git a/outscale/data_source_outscale_nets_test.go b/outscale/data_source_outscale_nets_test.go index d726a6b12..0971f58ce 100644 --- a/outscale/data_source_outscale_nets_test.go +++ b/outscale/data_source_outscale_nets_test.go @@ -10,7 +10,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPIVpcs_basic(t *testing.T) { +func TestAccNets_DataSource_basic(t *testing.T) { rand.Seed(time.Now().UTC().UnixNano()) ipRange := utils.RandVpcCidr() diff --git a/outscale/data_source_outscale_nic_test.go b/outscale/data_source_outscale_nic_test.go index 541d815e9..8e00238f5 100644 --- a/outscale/data_source_outscale_nic_test.go +++ b/outscale/data_source_outscale_nic_test.go @@ -3,7 +3,6 @@ package outscale import ( "context" "fmt" - "os" "strings" oscgo "github.com/outscale/osc-sdk-go/v2" @@ -16,10 +15,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIENIDataSource_basic(t *testing.T) { +func TestAccNet_WithNicDataSource_basic(t *testing.T) { t.Parallel() var conf oscgo.Nic - subregion := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -28,25 +26,20 @@ func TestAccOutscaleOAPIENIDataSource_basic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIENIDestroy, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIENIDataSourceConfig(subregion), + Config: testAccOutscaleOAPIENIDataSourceConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIENIExists("outscale_nic.outscale_nic", &conf), - testAccCheckOutscaleOAPIENIAttributes(&conf, subregion), + testAccCheckOutscaleOAPIENIAttributes(&conf, utils.GetRegion()), ), }, }, }) } -func TestAccOutscaleOAPIENIDataSource_basicFilter(t *testing.T) { +func TestAccNet_WithNicDataSource_basicFilter(t *testing.T) { t.Parallel() var conf oscgo.Nic - subregion := os.Getenv("OUTSCALE_REGION") - if subregion == "" { - subregion = "in-west-2" - } - resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, IDRefreshName: "outscale_nic.outscale_nic", @@ -54,10 +47,10 @@ func TestAccOutscaleOAPIENIDataSource_basicFilter(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIENIDestroy, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIENIDataSourceConfigFilter, + Config: testAccOutscaleOAPIENIDataSourceConfigFilter(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIENIExists("outscale_nic.outscale_nic", &conf), - testAccCheckOutscaleOAPIENIAttributes(&conf, subregion), + testAccCheckOutscaleOAPIENIAttributes(&conf, utils.GetRegion()), ), }, }, @@ -149,12 +142,12 @@ func testAccOutscaleOAPIENIDataSourceConfig(subregion string) string { resource "outscale_subnet" "outscale_subnet" { subregion_name = "%sa" - ip_range = "10.0.0.0/16" - net_id = "${outscale_net.outscale_net.id}" + ip_range = "10.0.0.0/24" + net_id = outscale_net.outscale_net.id } resource "outscale_nic" "outscale_nic" { - subnet_id = "${outscale_subnet.outscale_subnet.id}" + subnet_id = outscale_subnet.outscale_subnet.id tags { value = "tf-value" key = "tf-key" @@ -162,12 +155,13 @@ func testAccOutscaleOAPIENIDataSourceConfig(subregion string) string { } data "outscale_nic" "outscale_nic" { - nic_id = "${outscale_nic.outscale_nic.id}" + nic_id = outscale_nic.outscale_nic.id } `, subregion) } -const testAccOutscaleOAPIENIDataSourceConfigFilter = ` +func testAccOutscaleOAPIENIDataSourceConfigFilter(subregion string) string { + return fmt.Sprintf(` resource "outscale_net" "outscale_net" { ip_range = "10.0.0.0/16" @@ -178,13 +172,13 @@ const testAccOutscaleOAPIENIDataSourceConfigFilter = ` } resource "outscale_subnet" "outscale_subnet" { - subregion_name = "eu-west-2a" - ip_range = "10.0.0.0/16" - net_id = "${outscale_net.outscale_net.id}" + subregion_name = "%sa" + ip_range = "10.0.0.0/24" + net_id = outscale_net.outscale_net.id } resource "outscale_nic" "outscale_nic" { - subnet_id = "${outscale_subnet.outscale_subnet.id}" + subnet_id = outscale_subnet.outscale_subnet.id tags { value = "tf-value" key = "tf-key" @@ -194,7 +188,8 @@ const testAccOutscaleOAPIENIDataSourceConfigFilter = ` data "outscale_nic" "outscale_nic" { filter { name = "nic_ids" - values = ["${outscale_nic.outscale_nic.nic_id}"] - } + values = [outscale_nic.outscale_nic.nic_id] + } } -` +`, subregion) +} diff --git a/outscale/data_source_outscale_nics_test.go b/outscale/data_source_outscale_nics_test.go index cf9ba01a5..d5110bc98 100644 --- a/outscale/data_source_outscale_nics_test.go +++ b/outscale/data_source_outscale_nics_test.go @@ -2,21 +2,20 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPINicsDataSource(t *testing.T) { - subregion := os.Getenv("OUTSCALE_REGION") +func TestAccNet_WithNicsDataSource(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPINicsDataSourceConfig(subregion), + Config: testAccCheckOutscaleOAPINicsDataSourceConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.outscale_nics.outscale_nics", "nics.#", "1"), ), @@ -38,18 +37,18 @@ func testAccCheckOutscaleOAPINicsDataSourceConfig(subregion string) string { resource "outscale_subnet" "outscale_subnet" { subregion_name = "%sa" - ip_range = "10.0.0.0/16" - net_id = "${outscale_net.outscale_net.net_id}" + ip_range = "10.0.0.0/24" + net_id = outscale_net.outscale_net.net_id } resource "outscale_nic" "outscale_nic" { - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id } data "outscale_nics" "outscale_nics" { filter { name = "nic_ids" - values = ["${outscale_nic.outscale_nic.id}"] + values = [outscale_nic.outscale_nic.id] } } `, subregion) diff --git a/outscale/data_source_outscale_product_type_test.go b/outscale/data_source_outscale_product_type_test.go index 8154d15cf..356afeaf3 100644 --- a/outscale/data_source_outscale_product_type_test.go +++ b/outscale/data_source_outscale_product_type_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIProductType(t *testing.T) { +func TestAccOthers_DataSourceProductType(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/data_source_outscale_product_types_test.go b/outscale/data_source_outscale_product_types_test.go index 3c521fb5e..0a558edf8 100644 --- a/outscale/data_source_outscale_product_types_test.go +++ b/outscale/data_source_outscale_product_types_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIProductTypes(t *testing.T) { +func TestAccOthers_DataSourceProductTypes(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/data_source_outscale_public_catalog_test.go b/outscale/data_source_outscale_public_catalog_test.go index 2e9501c0c..dfdeec90f 100644 --- a/outscale/data_source_outscale_public_catalog_test.go +++ b/outscale/data_source_outscale_public_catalog_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIPublicCatalog_basic(t *testing.T) { +func TestAccOthers_DataSourcePublicCatalog_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/outscale/data_source_outscale_public_ip_test.go b/outscale/data_source_outscale_public_ip_test.go index b25290137..bf8c0a5a4 100644 --- a/outscale/data_source_outscale_public_ip_test.go +++ b/outscale/data_source_outscale_public_ip_test.go @@ -7,9 +7,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPIPublicIP(t *testing.T) { +func TestAccOthers_DataSourcePublicIP(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -26,7 +27,7 @@ func TestAccDataSourceOutscaleOAPIPublicIP(t *testing.T) { }) } -func TestAccDataSourceOutscaleOAPIPublicIPWithVM(t *testing.T) { +func TestAccVM_WithPublicIP(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") @@ -35,7 +36,7 @@ func TestAccDataSourceOutscaleOAPIPublicIPWithVM(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPIPublicIPConfigwithVM(omi), + Config: testAccDataSourceOutscaleOAPIPublicIPConfigwithVM(omi, utils.GetRegion()), }, }, }) @@ -76,7 +77,7 @@ func testAccDataSourceOutscaleOAPIPublicIPCheck(name string) resource.TestCheckF } } -func TestAccDataSourceOutscaleOAPIPublicIP_withTags(t *testing.T) { +func TestAccOthers_DataSourcePublicIP_withTags(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -93,13 +94,13 @@ const testAccDataSourceOutscaleOAPIPublicIPConfig = ` resource "outscale_public_ip" "test" {} data "outscale_public_ip" "by_public_ip_id" { - public_ip_id = "${outscale_public_ip.test.public_ip_id}" + public_ip_id = outscale_public_ip.test.public_ip_id } data "outscale_public_ip" "by_public_ip" { filter { name = "public_ips" - values = ["${outscale_public_ip.test.public_ip}"] + values = [outscale_public_ip.test.public_ip] } } ` @@ -125,7 +126,7 @@ const testAccDataSourceOutscaleOAPIPublicIPConfigWithTags = ` } ` -func testAccDataSourceOutscaleOAPIPublicIPConfigwithVM(omi string) string { +func testAccDataSourceOutscaleOAPIPublicIPConfigwithVM(omi, region string) string { return fmt.Sprintf(` resource "outscale_vm" "outscale_vm" { image_id = "%s" @@ -140,7 +141,7 @@ func testAccDataSourceOutscaleOAPIPublicIPConfigwithVM(omi string) string { } tags { key = "platform" - value = "eu-west-2" + value = "%[2]s" } tags { key = "project" @@ -159,5 +160,5 @@ func testAccDataSourceOutscaleOAPIPublicIPConfigwithVM(omi string) string { values = [outscale_public_ip_link.outscale_public_ip_link.link_public_ip_id] } } - `, omi) + `, omi, region) } diff --git a/outscale/data_source_outscale_public_ips_test.go b/outscale/data_source_outscale_public_ips_test.go index 10662682e..b765abed0 100644 --- a/outscale/data_source_outscale_public_ips_test.go +++ b/outscale/data_source_outscale_public_ips_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIPublicIPS(t *testing.T) { +func TestAccOthers_DataSourcePublicIPS(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -28,7 +28,7 @@ func TestAccDataSourceOutscaleOAPIPublicIPS(t *testing.T) { }) } -func TestAccDataSourceOutscaleOAPIPublicIPS_withTags(t *testing.T) { +func TestAccOthers_DataSourcePublicIPS_withTags(t *testing.T) { t.Parallel() if os.Getenv("TEST_QUOTA") == "true" { resource.Test(t, resource.TestCase{ diff --git a/outscale/data_source_outscale_quota_test.go b/outscale/data_source_outscale_quota_test.go index 92ff5c236..37633a6d2 100644 --- a/outscale/data_source_outscale_quota_test.go +++ b/outscale/data_source_outscale_quota_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIQuota(t *testing.T) { +func TestAccOthers_DataSourceQuota(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/data_source_outscale_quotas_test.go b/outscale/data_source_outscale_quotas_test.go index 7062de18b..c8809dc2a 100644 --- a/outscale/data_source_outscale_quotas_test.go +++ b/outscale/data_source_outscale_quotas_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourcesOutscaleOAPIQuotas(t *testing.T) { +func TestAccOthers_DataSourcesQuotas(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/data_source_outscale_regions_test.go b/outscale/data_source_outscale_regions_test.go index 485bef254..5c9f91e85 100644 --- a/outscale/data_source_outscale_regions_test.go +++ b/outscale/data_source_outscale_regions_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIRegionsDataSource_basic(t *testing.T) { +func TestAccOthers_RegionsDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/outscale/data_source_outscale_route_table_test.go b/outscale/data_source_outscale_route_table_test.go index 8919f3184..a345dadbd 100644 --- a/outscale/data_source_outscale_route_table_test.go +++ b/outscale/data_source_outscale_route_table_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccDataSourceOutscaleOAPIRouteTable_basic(t *testing.T) { +func TestAccNet_WithRouteTableDataSource_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, diff --git a/outscale/data_source_outscale_route_tables_test.go b/outscale/data_source_outscale_route_tables_test.go index fa526e3ea..934239b37 100644 --- a/outscale/data_source_outscale_route_tables_test.go +++ b/outscale/data_source_outscale_route_tables_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIRouteTables_basic(t *testing.T) { +func TestAccNet_WithRouteTablesDataSource_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/data_source_outscale_security_group_test.go b/outscale/data_source_outscale_security_group_test.go index bb11876cf..856159b2c 100644 --- a/outscale/data_source_outscale_security_group_test.go +++ b/outscale/data_source_outscale_security_group_test.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccDataSourceOutscaleOAPISecurityGroup_basic(t *testing.T) { +func TestAccNet_WithSecurityGroupDataSource_basic(t *testing.T) { t.Parallel() rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ @@ -27,7 +27,7 @@ func TestAccDataSourceOutscaleOAPISecurityGroup_basic(t *testing.T) { }) } -func TestAccDataSourceOutscaleOAPISecurityGroupPublic(t *testing.T) { +func TestAccNet_WithSecurityGroupPublic_(t *testing.T) { t.Parallel() rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ @@ -102,7 +102,7 @@ func testAccDataSourceOutscaleOAPISecurityGroupConfig(rInt int) string { #data "outscale_security_group" "by_filter" { # filter { # name = "security_group_names" - # values = ["${outscale_security_group.test.security_group_name}"] + # values = [outscale_security_group.test.security_group_name] # } #}`, rInt, rInt) } @@ -123,7 +123,7 @@ func testAccDataSourceOutscaleOAPISecurityGroupPublicConfig(rInt int) string { name = "security_group_names" // name = "group_name" - values = ["${outscale_security_group.test.security_group_name}"] + values = [outscale_security_group.test.security_group_name] } }`, rInt, rInt) } diff --git a/outscale/data_source_outscale_security_groups_test.go b/outscale/data_source_outscale_security_groups_test.go index 0d5f911bb..8d8fbc528 100644 --- a/outscale/data_source_outscale_security_groups_test.go +++ b/outscale/data_source_outscale_security_groups_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPISecurityGroups_vpc(t *testing.T) { +func TestAccNet_WIthSecurityGroups_DataSource(t *testing.T) { rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/data_source_outscale_server_certificate_test.go b/outscale/data_source_outscale_server_certificate_test.go index bf68db7a0..b4b80e140 100644 --- a/outscale/data_source_outscale_server_certificate_test.go +++ b/outscale/data_source_outscale_server_certificate_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform/helper/acctest" ) -func TestAccOutscaleOAPIServerCertificateDatasource_basic(t *testing.T) { +func TestAccOthers_ServerCertificateDatasource_basic(t *testing.T) { t.Parallel() rName := acctest.RandomWithPrefix("acc-test") body := `-----BEGIN CERTIFICATE----- diff --git a/outscale/data_source_outscale_server_certificates_test.go b/outscale/data_source_outscale_server_certificates_test.go index 87d4afc47..cf3cce28d 100644 --- a/outscale/data_source_outscale_server_certificates_test.go +++ b/outscale/data_source_outscale_server_certificates_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPIServerCertificatesDatasource_basic(t *testing.T) { +func TestAccOthers_ServerCertificatesDatasource_basic(t *testing.T) { t.Parallel() rName := acctest.RandomWithPrefix("acc-test") body := `-----BEGIN CERTIFICATE----- diff --git a/outscale/data_source_outscale_snapshot_export_task_test.go b/outscale/data_source_outscale_snapshot_export_task_test.go index d1bfcd7ff..0896a71a9 100644 --- a/outscale/data_source_outscale_snapshot_export_task_test.go +++ b/outscale/data_source_outscale_snapshot_export_task_test.go @@ -5,12 +5,13 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPISnapshotExportTaskDataSource_basic(t *testing.T) { +func TestAccOthers_SnapshotExportTaskDataSource_basic(t *testing.T) { t.Parallel() imageName := acctest.RandomWithPrefix("terraform-export-") resource.Test(t, resource.TestCase{ @@ -20,7 +21,7 @@ func TestAccOutscaleOAPISnapshotExportTaskDataSource_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotExportTaskDataSourceConfig(imageName), + Config: testAccOutscaleOAPISnapshotExportTaskDataSourceConfig(imageName, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleSnapshotExportTaskDataSourceID("data.outscale_snapshot_export_task.export_task"), ), @@ -44,10 +45,10 @@ func testAccCheckOutscaleSnapshotExportTaskDataSourceID(n string) resource.TestC } } -func testAccOutscaleOAPISnapshotExportTaskDataSourceConfig(testName string) string { +func testAccOutscaleOAPISnapshotExportTaskDataSourceConfig(testName, region string) string { var stringTemplate = ` resource "outscale_volume" "outscale_volume_snap" { - subregion_name = "eu-west-2a" + subregion_name = "%[2]sa" size = 10 } @@ -59,7 +60,7 @@ func testAccOutscaleOAPISnapshotExportTaskDataSourceConfig(testName string) stri snapshot_id = outscale_snapshot.outscale_snapshot.snapshot_id osu_export { disk_image_format = "qcow2" - osu_bucket = "%s" + osu_bucket = "%[1]s" osu_prefix = "new-export" } } @@ -71,5 +72,5 @@ func testAccOutscaleOAPISnapshotExportTaskDataSourceConfig(testName string) stri } } ` - return fmt.Sprintf(stringTemplate, testName) + return fmt.Sprintf(stringTemplate, testName, region) } diff --git a/outscale/data_source_outscale_snapshot_export_tasks_test.go b/outscale/data_source_outscale_snapshot_export_tasks_test.go index 10e2553b5..85e3f6bbf 100644 --- a/outscale/data_source_outscale_snapshot_export_tasks_test.go +++ b/outscale/data_source_outscale_snapshot_export_tasks_test.go @@ -6,9 +6,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPISnapshotExportTasksDataSource_basic(t *testing.T) { +func TestAccOthers_SnapshotExportTasksDataSource_basic(t *testing.T) { imageName := acctest.RandomWithPrefix("terraform-export") resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -17,7 +18,7 @@ func TestAccOutscaleOAPISnapshotExportTasksDataSource_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotExportTasksDataSourceConfig(imageName), + Config: testAccOutscaleOAPISnapshotExportTasksDataSourceConfig(imageName, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleSnapshotExportTaskDataSourceID("data.outscale_snapshot_export_tasks.export_tasks"), ), @@ -26,14 +27,14 @@ func TestAccOutscaleOAPISnapshotExportTasksDataSource_basic(t *testing.T) { }) } -func testAccOutscaleOAPISnapshotExportTasksDataSourceConfig(testName string) string { - var stringTemplate = ` +func testAccOutscaleOAPISnapshotExportTasksDataSourceConfig(testName, region string) string { + return fmt.Sprintf(` resource "outscale_volume" "outscale_volume_snap" { - subregion_name = "eu-west-2a" + subregion_name = "%[2]sa" size = 10 } - resource "outscale_snapshot" "outscale_snapshot" { + resource "outscale_snapshot" "outscale_snapshot" { volume_id = outscale_volume.outscale_volume_snap.volume_id } @@ -41,7 +42,7 @@ func testAccOutscaleOAPISnapshotExportTasksDataSourceConfig(testName string) str snapshot_id = outscale_snapshot.outscale_snapshot.snapshot_id osu_export { disk_image_format = "qcow2" - osu_bucket = "%s" + osu_bucket = "%[1]s" osu_prefix = "new-export" } } @@ -52,6 +53,5 @@ func testAccOutscaleOAPISnapshotExportTasksDataSourceConfig(testName string) str values = [outscale_snapshot_export_task.outscale_snapshot_export_task.id] } } - ` - return fmt.Sprintf(stringTemplate, testName) +`, testName, region) } diff --git a/outscale/data_source_outscale_snapshot_test.go b/outscale/data_source_outscale_snapshot_test.go index e00e1f673..ed3d92342 100644 --- a/outscale/data_source_outscale_snapshot_test.go +++ b/outscale/data_source_outscale_snapshot_test.go @@ -2,23 +2,22 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPISnapshotDataSource_basic(t *testing.T) { +func TestAccOthers_SnapshotDataSource_basic(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPISnapshotDataSourceConfig(region), + Config: testAccCheckOutscaleOAPISnapshotDataSourceConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISnapshotDataSourceID("data.outscale_snapshot.snapshot"), resource.TestCheckResourceAttr("data.outscale_snapshot.snapshot", "volume_size", "1"), @@ -28,16 +27,15 @@ func TestAccOutscaleOAPISnapshotDataSource_basic(t *testing.T) { }) } -func TestAccOutscaleOAPISnapshotDataSource_multipleFilters(t *testing.T) { +func TestAccOthers_SnapshotDataSource_multipleFilters(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPISnapshotDataSourceConfigWithMultipleFilters(region), + Config: testAccCheckOutscaleOAPISnapshotDataSourceConfigWithMultipleFilters(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISnapshotDataSourceID("data.outscale_snapshot.snapshot"), resource.TestCheckResourceAttr("data.outscale_snapshot.snapshot", "volume_size", "10"), @@ -69,11 +67,11 @@ func testAccCheckOutscaleOAPISnapshotDataSourceConfig(region string) string { } resource "outscale_snapshot" "snapshot" { - volume_id = "${outscale_volume.example.id}" + volume_id = outscale_volume.example.id } data "outscale_snapshot" "snapshot" { - snapshot_id = "${outscale_snapshot.snapshot.id}" + snapshot_id = outscale_snapshot.snapshot.id } `, region) } @@ -86,11 +84,11 @@ func testAccCheckOutscaleOAPISnapshotDataSourceConfigWithMultipleFilters(region } resource "outscale_snapshot" "snapshot" { - volume_id = "${outscale_volume.external1.id}" + volume_id = outscale_volume.external1.id } data "outscale_snapshot" "snapshot" { - snapshot_id = "${outscale_snapshot.snapshot.id}" + snapshot_id = outscale_snapshot.snapshot.id filter { name = "volume_sizes" diff --git a/outscale/data_source_outscale_snapshots_test.go b/outscale/data_source_outscale_snapshots_test.go index 43c968107..9c2ee4647 100644 --- a/outscale/data_source_outscale_snapshots_test.go +++ b/outscale/data_source_outscale_snapshots_test.go @@ -1,18 +1,22 @@ package outscale import ( + "fmt" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPISnapshotsDataSource_basic(t *testing.T) { +func TestAccOthers_SnapshotsDataSource_basic(t *testing.T) { + t.Parallel() + resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPISnapshotsDataSourceConfig, + Config: testAccCheckOutscaleOAPISnapshotsDataSourceConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.outscale_snapshots.outscale_snapshots", "snapshots.#", "1"), ), @@ -21,17 +25,19 @@ func TestAccOutscaleOAPISnapshotsDataSource_basic(t *testing.T) { }) } -const testAccCheckOutscaleOAPISnapshotsDataSourceConfig = ` +func testAccCheckOutscaleOAPISnapshotsDataSourceConfig(region string) string { + return fmt.Sprintf(` resource "outscale_volume" "example" { - subregion_name = "eu-west-2a" + subregion_name = "%sa" size = 1 } resource "outscale_snapshot" "snapshot" { - volume_id = "${outscale_volume.example.id}" + volume_id = outscale_volume.example.id } data "outscale_snapshots" "outscale_snapshots" { - snapshot_id = ["${outscale_snapshot.snapshot.id}"] + snapshot_id = [outscale_snapshot.snapshot.id] } -` +`, region) +} diff --git a/outscale/data_source_outscale_subnet_test.go b/outscale/data_source_outscale_subnet_test.go index c75165d77..8cbe32c90 100644 --- a/outscale/data_source_outscale_subnet_test.go +++ b/outscale/data_source_outscale_subnet_test.go @@ -6,16 +6,16 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPISubnet(t *testing.T) { - t.Parallel() +func TestAccNet_WithSubnet_DataSource(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPISubnetConfig, + Config: testAccDataSourceOutscaleOAPISubnetConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccDataSourceOutscaleOAPISubnetCheck("data.outscale_subnet.by_id"), testAccDataSourceOutscaleOAPISubnetCheck("data.outscale_subnet.by_filter"), @@ -25,14 +25,13 @@ func TestAccDataSourceOutscaleOAPISubnet(t *testing.T) { }) } -func TestAccDataSourceOutscaleOAPISubnet_withAvailableIpsCountsFilter(t *testing.T) { - t.Parallel() +func TestAccNet_SubnetDataSource_withAvailableIpsCountsFilter(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPISubnetWithAvailableIpsCountsFilter(), + Config: testAccDataSourceOutscaleOAPISubnetWithAvailableIpsCountsFilter(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccDataSourceOutscaleOAPISubnetCheck("data.outscale_subnet.by_filter"), ), @@ -54,6 +53,7 @@ func testAccDataSourceOutscaleOAPISubnetCheck(name string) resource.TestCheckFun } attr := rs.Primary.Attributes + subregion := fmt.Sprintf("%sa", utils.GetRegion()) if attr["id"] != subnetRs.Primary.Attributes["id"] { return fmt.Errorf( @@ -63,10 +63,10 @@ func testAccDataSourceOutscaleOAPISubnetCheck(name string) resource.TestCheckFun ) } - if attr["ip_range"] != "10.0.0.0/16" { + if attr["ip_range"] != "10.0.0.0/24" { return fmt.Errorf("bad ip_range %s", attr["ip_range"]) } - if attr["subregion_name"] != "eu-west-2a" { + if attr["subregion_name"] != subregion { return fmt.Errorf("bad subregion_name %s", attr["subregion_name"]) } @@ -74,35 +74,38 @@ func testAccDataSourceOutscaleOAPISubnetCheck(name string) resource.TestCheckFun } } -const testAccDataSourceOutscaleOAPISubnetConfig = ` - resource "outscale_net" "outscale_net" { - ip_range = "10.0.0.0/16" - tags { - key = "Name" - value = "testacc-subet-ds" +func testAccDataSourceOutscaleOAPISubnetConfig(region string) string { + return fmt.Sprintf(` + resource "outscale_net" "outscale_net" { + ip_range = "10.0.0.0/16" + tags { + key = "Name" + value = "testacc-subet-ds" + } } - } - resource "outscale_subnet" "outscale_subnet" { - net_id = outscale_net.outscale_net.net_id - ip_range = "10.0.0.0/16" - subregion_name = "eu-west-2a" - } + resource "outscale_subnet" "outscale_subnet" { + net_id = outscale_net.outscale_net.net_id + ip_range = "10.0.0.0/24" + subregion_name = "%sa" + } - data "outscale_subnet" "by_id" { - subnet_id = outscale_subnet.outscale_subnet.id - } + data "outscale_subnet" "by_id" { + subnet_id = outscale_subnet.outscale_subnet.id + } - data "outscale_subnet" "by_filter" { - filter { - name = "subnet_ids" - values = [outscale_subnet.outscale_subnet.id] + data "outscale_subnet" "by_filter" { + filter { + name = "subnet_ids" + values = [outscale_subnet.outscale_subnet.id] + } } - } -` -func testAccDataSourceOutscaleOAPISubnetWithAvailableIpsCountsFilter() string { - return ` + `, region) +} + +func testAccDataSourceOutscaleOAPISubnetWithAvailableIpsCountsFilter(region string) string { + return fmt.Sprintf(` resource "outscale_net" "outscale_net" { ip_range = "10.0.0.0/16" tags { @@ -112,8 +115,8 @@ func testAccDataSourceOutscaleOAPISubnetWithAvailableIpsCountsFilter() string { } resource "outscale_subnet" "outscale_subnet" { - subregion_name = "eu-west-2a" - ip_range = "10.0.0.0/16" + subregion_name = "%sa" + ip_range = "10.0.0.0/24" net_id = outscale_net.outscale_net.net_id } @@ -123,5 +126,5 @@ func testAccDataSourceOutscaleOAPISubnetWithAvailableIpsCountsFilter() string { values = [outscale_subnet.outscale_subnet.available_ips_count] } } - ` + `, region) } diff --git a/outscale/data_source_outscale_subnets_test.go b/outscale/data_source_outscale_subnets_test.go index 6b686d957..c5219cee2 100644 --- a/outscale/data_source_outscale_subnets_test.go +++ b/outscale/data_source_outscale_subnets_test.go @@ -8,7 +8,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccDataSourceOutscaleOAPISubnets(t *testing.T) { +func TestAccNet_WithSubnetsDataSource(t *testing.T) { t.Parallel() rInt := utils.RandIntRange(16, 31) @@ -17,7 +17,7 @@ func TestAccDataSourceOutscaleOAPISubnets(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPISubnetsConfig(rInt), + Config: testAccDataSourceOutscaleOAPISubnetsConfig(rInt, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr("data.outscale_subnets.by_filter", "subnets.#", "1"), ), @@ -26,23 +26,23 @@ func TestAccDataSourceOutscaleOAPISubnets(t *testing.T) { }) } -func TestAccDataSourceOutscaleOAPISubnets_withAvailableIpsCountsFilter(t *testing.T) { +func TestAccNet_Subnets_withAvailableIpsCountsFilter(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccDataSourceOutscaleOAPISubnetsWithAvailableIpsCountsFilter(), + Config: testAccDataSourceOutscaleOAPISubnetsWithAvailableIpsCountsFilter(utils.GetRegion()), }, }, }) } -func testAccDataSourceOutscaleOAPISubnetsConfig(rInt int) string { +func testAccDataSourceOutscaleOAPISubnetsConfig(rInt int, region string) string { return fmt.Sprintf(` resource "outscale_net" "net" { - ip_range = "172.%[1]d.123.0/24" + ip_range = "10.%[1]d.123.0/24" tags { key = "Name" @@ -51,8 +51,8 @@ func testAccDataSourceOutscaleOAPISubnetsConfig(rInt int) string { } resource "outscale_subnet" "subnet" { - ip_range = "172.%[1]d.123.0/24" - subregion_name = "eu-west-2a" + ip_range = "10.%[1]d.123.0/24" + subregion_name = "%[2]sa" net_id = "${outscale_net.net.id}" tags { @@ -67,11 +67,11 @@ func testAccDataSourceOutscaleOAPISubnetsConfig(rInt int) string { values = ["${outscale_subnet.subnet.id}"] } } - `, rInt) + `, rInt, region) } -func testAccDataSourceOutscaleOAPISubnetsWithAvailableIpsCountsFilter() string { - return ` +func testAccDataSourceOutscaleOAPISubnetsWithAvailableIpsCountsFilter(region string) string { + return fmt.Sprintf(` resource "outscale_net" "outscale_net1" { ip_range = "10.0.0.0/16" tags { @@ -89,13 +89,13 @@ func testAccDataSourceOutscaleOAPISubnetsWithAvailableIpsCountsFilter() string { } resource "outscale_subnet" "sub1" { - subregion_name = "eu-west-2a" + subregion_name = "%[1]sa" ip_range = "10.0.0.0/16" net_id = outscale_net.outscale_net1.net_id } resource "outscale_subnet" "sub2" { - subregion_name = "eu-west-2a" + subregion_name = "%[1]sa" ip_range = "10.0.0.0/16" net_id = outscale_net.outscale_net2.net_id } @@ -104,8 +104,8 @@ func testAccDataSourceOutscaleOAPISubnetsWithAvailableIpsCountsFilter() string { data "outscale_subnets" "by_filter" { filter { name = "available_ips_counts" - values = ["${outscale_subnet.sub1.available_ips_count}", "${outscale_subnet.sub2.available_ips_count}"] + values = [outscale_subnet.sub1.available_ips_count, outscale_subnet.sub2.available_ips_count] } } - ` + `, region) } diff --git a/outscale/data_source_outscale_subregions_test.go b/outscale/data_source_outscale_subregions_test.go index 53f22e455..9df932512 100644 --- a/outscale/data_source_outscale_subregions_test.go +++ b/outscale/data_source_outscale_subregions_test.go @@ -6,11 +6,11 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPISubregionsDataSource_Basic(t *testing.T) { +func TestAccOthers_SubregionsDataSource_Basic(t *testing.T) { t.Parallel() - subregionName := "eu-west-2b" resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,7 +19,7 @@ func TestAccOutscaleOAPISubregionsDataSource_Basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPISubregionsDataSourceConfig(subregionName), + Config: testAccCheckOutscaleOAPISubregionsDataSourceConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISubregionsDataSourceID("data.outscale_subregions.test"), ), @@ -28,7 +28,7 @@ func TestAccOutscaleOAPISubregionsDataSource_Basic(t *testing.T) { }) } -func TestAccOutscaleOAPISubregionsDataSource_All(t *testing.T) { +func TestAccOthers_SubregionsDataSource_All(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/outscale/data_source_outscale_tag_test.go b/outscale/data_source_outscale_tag_test.go index 875f13e46..20c5e513e 100644 --- a/outscale/data_source_outscale_tag_test.go +++ b/outscale/data_source_outscale_tag_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPITagDataSource(t *testing.T) { +func TestAccVM_WithTagDataSource(t *testing.T) { omi := os.Getenv("OUTSCALE_IMAGEID") resource.Test(t, resource.TestCase{ diff --git a/outscale/data_source_outscale_virtual_gateway_test.go b/outscale/data_source_outscale_virtual_gateway_test.go index b075ed0eb..b2d47c83b 100644 --- a/outscale/data_source_outscale_virtual_gateway_test.go +++ b/outscale/data_source_outscale_virtual_gateway_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIVirtualGateway_unattached(t *testing.T) { +func TestAccOthers_DataSourceVirtualGateway_unattached(t *testing.T) { //t.Skip() t.Parallel() rInt := acctest.RandInt() @@ -40,7 +40,7 @@ func testAccDataSourceOutscaleOAPIVirtualGatewayUnattachedConfig(rInt int) strin } data "outscale_virtual_gateway" "test_by_id" { - virtual_gateway_id = "${outscale_virtual_gateway.unattached.id}" + virtual_gateway_id = outscale_virtual_gateway.unattached.id } `) } diff --git a/outscale/data_source_outscale_virtual_gateways_test.go b/outscale/data_source_outscale_virtual_gateways_test.go index f86d1bfdb..f790b9214 100644 --- a/outscale/data_source_outscale_virtual_gateways_test.go +++ b/outscale/data_source_outscale_virtual_gateways_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIVpnGateways_unattached(t *testing.T) { +func TestAccOthers_DataSourceVpnGateways_unattached(t *testing.T) { //t.Skip() t.Parallel() rInt := acctest.RandInt() @@ -33,7 +33,7 @@ func testAccDataSourceOutscaleOAPIVpnGatewaysUnattachedConfig(rInt int) string { } data "outscale_virtual_gateways" "test_by_id" { - virtual_gateway_id = ["${outscale_virtual_gateway.unattached.id}"] + virtual_gateway_id = [outscale_virtual_gateway.unattached.id] } `) } diff --git a/outscale/data_source_outscale_vm_state_test.go b/outscale/data_source_outscale_vm_state_test.go index 68b93e5b4..66871bc9f 100644 --- a/outscale/data_source_outscale_vm_state_test.go +++ b/outscale/data_source_outscale_vm_state_test.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccDataSourceOutscaleOAPIVmState(t *testing.T) { +func TestAccVM_StateDataSource(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") diff --git a/outscale/data_source_outscale_vm_states_test.go b/outscale/data_source_outscale_vm_states_test.go index dd81749cd..a5209f333 100644 --- a/outscale/data_source_outscale_vm_states_test.go +++ b/outscale/data_source_outscale_vm_states_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIVMStates(t *testing.T) { +func TestAccVM_StatesDataSource(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") diff --git a/outscale/data_source_outscale_vm_test.go b/outscale/data_source_outscale_vm_test.go index 1486409bf..6b13a3383 100644 --- a/outscale/data_source_outscale_vm_test.go +++ b/outscale/data_source_outscale_vm_test.go @@ -6,9 +6,10 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIVMDataSource_basic(t *testing.T) { +func TestAccVM_DataSource_basic(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") datasourcceName := "data.outscale_vm.basic_web" @@ -18,7 +19,7 @@ func TestAccOutscaleOAPIVMDataSource_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOAPIVMDataSourceConfig(omi, "tinav4.c2r2p2"), + Config: testAccOAPIVMDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion()), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(datasourcceName, "image_id", omi), resource.TestCheckResourceAttr(datasourcceName, "vm_type", "tinav4.c2r2p2"), @@ -29,28 +30,13 @@ func TestAccOutscaleOAPIVMDataSource_basic(t *testing.T) { }) } -func testAccOAPIVMDataSourceConfig(omi, vmType string) string { +func testAccOAPIVMDataSourceConfig(omi, vmType, region string) string { return fmt.Sprintf(` - resource "outscale_net" "outscale_net" { - ip_range = "10.0.0.0/16" - tags { - key = "Name" - value = "testacc-vm-ds" - } - } - - 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" - } - - resource "outscale_vm" "outscale_vm" { - image_id = "%s" - vm_type = "%s" + resource "outscale_vm" "outscale_vm" { + image_id = "%[1]s" + vm_type = "%[2]s" keypair_name = "terraform-basic" - subnet_id = outscale_subnet.outscale_subnet.subnet_id tags { key = "name" @@ -58,11 +44,11 @@ func testAccOAPIVMDataSourceConfig(omi, vmType string) string { } } - data "outscale_vm" "basic_web" { - filter { + data "outscale_vm" "basic_web" { + filter { name = "vm_ids" values = [outscale_vm.outscale_vm.vm_id] - } + } } - `, omi, vmType) + `, omi, vmType, region) } diff --git a/outscale/data_source_outscale_vm_types_test.go b/outscale/data_source_outscale_vm_types_test.go index a48784442..86e990399 100644 --- a/outscale/data_source_outscale_vm_types_test.go +++ b/outscale/data_source_outscale_vm_types_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccDataSourceOutscaleOAPIVMTypes_basic(t *testing.T) { +func TestAccVM_TypesDataSource_basic(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") diff --git a/outscale/data_source_outscale_vms_test.go b/outscale/data_source_outscale_vms_test.go index 821808c34..20cfa0d3d 100644 --- a/outscale/data_source_outscale_vms_test.go +++ b/outscale/data_source_outscale_vms_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPIVMSDataSource_basic(t *testing.T) { +func TestAccVMS_DataSource_basic(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") diff --git a/outscale/data_source_outscale_volume_test.go b/outscale/data_source_outscale_volume_test.go index 316d2e1a1..cfa21c497 100644 --- a/outscale/data_source_outscale_volume_test.go +++ b/outscale/data_source_outscale_volume_test.go @@ -2,23 +2,22 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIVolumeDataSource_basic(t *testing.T) { +func TestAccOthers_VolumeDataSource_basic(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVolumeDataSourceConfig(region), + Config: testAccCheckOutscaleOAPIVolumeDataSourceConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVolumeDataSourceID("data.outscale_volume.ebs_volume"), resource.TestCheckResourceAttr("data.outscale_volume.ebs_volume", "size", "10"), @@ -29,16 +28,15 @@ func TestAccOutscaleOAPIVolumeDataSource_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIVolumeDataSource_filterByTags(t *testing.T) { +func TestAccOthers_VolumeDataSource_filterByTags(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVolumeDataSourceConfigFilterByTags(region), + Config: testAccCheckOutscaleOAPIVolumeDataSourceConfigFilterByTags(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVolumeDataSourceID("data.outscale_volume.ebs_volume"), resource.TestCheckResourceAttr("data.outscale_volume.ebs_volume", "size", "10"), @@ -79,7 +77,7 @@ func testAccCheckOutscaleOAPIVolumeDataSourceConfig(region string) string { data "outscale_volume" "ebs_volume" { filter { name = "volume_ids" - values = ["${outscale_volume.example.id}"] + values = [outscale_volume.example.id] } } `, region) @@ -106,7 +104,7 @@ func testAccCheckOutscaleOAPIVolumeDataSourceConfigFilterByTags(region string) s filter { name = "volume_ids" - values = ["${outscale_volume.example.id}"] + values = [outscale_volume.example.id] } } diff --git a/outscale/data_source_outscale_volumes_test.go b/outscale/data_source_outscale_volumes_test.go index e0dd64975..b2a6e8da0 100644 --- a/outscale/data_source_outscale_volumes_test.go +++ b/outscale/data_source_outscale_volumes_test.go @@ -6,18 +6,18 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIVolumesDataSource_multipleFilters(t *testing.T) { +func TestAccOthers_VolumesDataSource_multipleFilters(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVolumeDataSourceConfigWithMultipleFilters(region), + Config: testAccCheckOutscaleOAPIVolumeDataSourceConfigWithMultipleFilters(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVolumeDataSourceID("data.outscale_volumes.ebs_volume"), resource.TestCheckResourceAttr("data.outscale_volumes.ebs_volume", "volumes.0.size", "1"), @@ -28,16 +28,15 @@ func TestAccOutscaleOAPIVolumesDataSource_multipleFilters(t *testing.T) { }) } -func TestAccOutscaleOAPIVolumeDataSource_multipleVIdsFilters(t *testing.T) { +func TestAccOthers_VolumeDataSource_multipleVIdsFilters(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVolumesDataSourceConfigWithMultipleVolumeIDsFilter(region), + Config: testAccCheckOutscaleOAPIVolumesDataSourceConfigWithMultipleVolumeIDsFilter(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVolumeDataSourceID("data.outscale_volumes.outscale_volumes"), resource.TestCheckResourceAttr("data.outscale_volumes.outscale_volumes", "volumes.0.size", "40"), @@ -47,9 +46,8 @@ func TestAccOutscaleOAPIVolumeDataSource_multipleVIdsFilters(t *testing.T) { }) } -func TestAccOutscaleOAPIVolumesDataSource_withVM(t *testing.T) { +func TestAccVM_withVolumesDataSource(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") omi := os.Getenv("OUTSCALE_IMAGEID") keypair := os.Getenv("OUTSCALE_KEYPAIR") sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") @@ -59,7 +57,7 @@ func TestAccOutscaleOAPIVolumesDataSource_withVM(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVolumesDataSourceConfigWithVM(region, omi, keypair, sgId), + Config: testAccCheckOutscaleOAPIVolumesDataSourceConfigWithVM(utils.GetRegion(), omi, keypair, sgId), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVolumeDataSourceID("data.outscale_volumes.outscale_volumes"), // resource.TestCheckResourceAttr("data.outscale_volumes.outscale_volumes", "volumes.0.size", "1"), @@ -86,12 +84,12 @@ func testAccCheckOutscaleOAPIVolumeDataSourceConfigWithMultipleFilters(region st data "outscale_volumes" "ebs_volume" { filter { name = "volume_sizes" - values = ["${outscale_volume.external.size}"] + values = [outscale_volume.external.size] } filter { name = "volume_types" - values = ["${outscale_volume.external.volume_type}"] + values = [outscale_volume.external.volume_type] } } `, region) @@ -112,7 +110,7 @@ func testAccCheckOutscaleOAPIVolumesDataSourceConfigWithMultipleVolumeIDsFilter( data "outscale_volumes" "outscale_volumes" { filter { name = "volume_ids" - values = ["${outscale_volume.outscale_volume.volume_id}", "${outscale_volume.outscale_volume2.volume_id}"] + values = [outscale_volume.outscale_volume.volume_id, outscale_volume.outscale_volume2.volume_id] } } `, region) @@ -143,20 +141,10 @@ func testAccCheckOutscaleOAPIVolumesDataSourceConfigWithVM(region, imageID, keyp resource "outscale_volume" "outscale_volume3" { subregion_name = "%[1]sa" size = 40 - iops = 100 - volume_type = "io1" + volume_type = "gp2" tags { key = "type" - value = "io1" - } - } - - resource "outscale_net" "net" { - ip_range = "10.0.0.0/16" - - tags { - key = "Name" - value = "testacc-security-group-rs" + value = "gp2" } } @@ -168,8 +156,6 @@ func testAccCheckOutscaleOAPIVolumesDataSourceConfigWithVM(region, imageID, keyp key = "Name" value = "tf-acc-test" } - - net_id = "${outscale_net.net.id}" } resource "outscale_vm" "outscale_vm" { @@ -181,26 +167,26 @@ func testAccCheckOutscaleOAPIVolumesDataSourceConfigWithVM(region, imageID, keyp resource "outscale_volumes_link" "outscale_volumes_link" { device_name = "/dev/xvdc" - volume_id = "${outscale_volume.outscale_volume.id}" - vm_id = "${outscale_vm.outscale_vm.id}" + volume_id = outscale_volume.outscale_volume.id + vm_id = outscale_vm.outscale_vm.id } resource "outscale_volumes_link" "outscale_volumes_link_2" { device_name = "/dev/xvdd" - volume_id = "${outscale_volume.outscale_volume2.id}" - vm_id = "${outscale_vm.outscale_vm.id}" + volume_id = outscale_volume.outscale_volume2.id + vm_id = outscale_vm.outscale_vm.id } resource "outscale_volumes_link" "outscale_volumes_link_3" { device_name = "/dev/xvde" - volume_id = "${outscale_volume.outscale_volume3.id}" - vm_id = "${outscale_vm.outscale_vm.id}" + volume_id = outscale_volume.outscale_volume3.id + vm_id = outscale_vm.outscale_vm.id } data "outscale_volumes" "outscale_volumes" { filter { name = "link_volume_vm_ids" - values = ["${outscale_vm.outscale_vm.vm_id}"] + values = [outscale_vm.outscale_vm.vm_id] } } `, region, imageID, keypair, sgId) diff --git a/outscale/data_source_outscale_vpn_connection_test.go b/outscale/data_source_outscale_vpn_connection_test.go index 66a425f6a..44605d8b4 100644 --- a/outscale/data_source_outscale_vpn_connection_test.go +++ b/outscale/data_source_outscale_vpn_connection_test.go @@ -9,7 +9,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleVPNConnectionDataSource_basic(t *testing.T) { +func TestAccOthers_VPNConnectionDataSource_basic(t *testing.T) { t.Parallel() publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255)) @@ -24,7 +24,7 @@ func TestAccOutscaleVPNConnectionDataSource_basic(t *testing.T) { }) } -func TestAccOutscaleVPNConnectionDataSource_withFilters(t *testing.T) { +func TestAccOthers_VPNConnectionDataSource_withFilters(t *testing.T) { t.Parallel() publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255)) diff --git a/outscale/data_source_outscale_vpn_connections_test.go b/outscale/data_source_outscale_vpn_connections_test.go index 1d6b52d6c..187c76a76 100644 --- a/outscale/data_source_outscale_vpn_connections_test.go +++ b/outscale/data_source_outscale_vpn_connections_test.go @@ -8,7 +8,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleVPNConnectionsDataSource_basic(t *testing.T) { +func TestAccOthers_VPNConnectionsDataSource_basic(t *testing.T) { t.Parallel() publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255)) @@ -23,7 +23,7 @@ func TestAccOutscaleVPNConnectionsDataSource_basic(t *testing.T) { }) } -func TestAccOutscaleVPNConnectionsDataSource_withFilters(t *testing.T) { +func TestAccOthers_VPNConnectionsDataSource_withFilters(t *testing.T) { t.Parallel() publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255)) diff --git a/outscale/import_outscale_net_attributes_test.go b/outscale/import_outscale_net_attributes_test.go index f6aca696f..4ab74b0f8 100644 --- a/outscale/import_outscale_net_attributes_test.go +++ b/outscale/import_outscale_net_attributes_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleNetAttr_import(t *testing.T) { +func TestAccNet_Attr_import(t *testing.T) { t.Parallel() resourceName := "outscale_net_attributes.outscale_net_attributes" diff --git a/outscale/resource_outscale_access_key_test.go b/outscale/resource_outscale_access_key_test.go index c8a177742..c2ddfbd46 100644 --- a/outscale/resource_outscale_access_key_test.go +++ b/outscale/resource_outscale_access_key_test.go @@ -12,7 +12,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleAccessKey_basic(t *testing.T) { +func TestAccOthers_AccessKey_basic(t *testing.T) { t.Parallel() resourceName := "outscale_access_key.outscale_access_key" @@ -38,7 +38,7 @@ func TestAccOutscaleAccessKey_basic(t *testing.T) { }) } -func TestAccOutscaleAccessKey_updatedToInactivedKey(t *testing.T) { +func TestAccOthers_AccessKey_updatedToInactivedKey(t *testing.T) { t.Parallel() resourceName := "outscale_access_key.outscale_access_key" @@ -80,7 +80,7 @@ func TestAccOutscaleAccessKey_updatedToInactivedKey(t *testing.T) { }) } -func TestAccOutscaleAccessKey_updatedToActivedKey(t *testing.T) { +func TestAccOthers_AccessKey_updatedToActivedKey(t *testing.T) { resourceName := "outscale_access_key.outscale_access_key" state := "INACTIVE" @@ -121,7 +121,7 @@ func TestAccOutscaleAccessKey_updatedToActivedKey(t *testing.T) { }) } -func TestAccOutscaleAccessKey_updatedExpirationDate(t *testing.T) { +func TestAccOthers_AccessKey_updatedExpirationDate(t *testing.T) { resourceName := "outscale_access_key.outscale_access_key" expirDate := time.Now().AddDate(1, 1, 0).Format("2006-01-02") expirDateUpdated := time.Now().AddDate(1, 4, 0).Format("2006-01-02") diff --git a/outscale/resource_outscale_api_access_rule_test.go b/outscale/resource_outscale_api_access_rule_test.go index be8f9fee8..01f2ae58d 100644 --- a/outscale/resource_outscale_api_access_rule_test.go +++ b/outscale/resource_outscale_api_access_rule_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIApiAccessRule_basic(t *testing.T) { +func TestAccOthers_AccessRule_basic(t *testing.T) { t.Parallel() resourceName := "outscale_api_access_rule.rule_test" @@ -124,7 +124,7 @@ resource "outscale_ca" "ca_rule" { } resource "outscale_api_access_rule" "rule_test" { - ca_ids = ["${outscale_ca.ca_rule.id}"] + ca_ids = [outscale_ca.ca_rule.id] ip_ranges = ["192.0.2.0/16"] description = "testing api access rule" } diff --git a/outscale/resource_outscale_ca_test.go b/outscale/resource_outscale_ca_test.go index 6c70a3d79..1ddc934b5 100644 --- a/outscale/resource_outscale_ca_test.go +++ b/outscale/resource_outscale_ca_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPICa_basic(t *testing.T) { +func TestAccOthers_Ca_basic(t *testing.T) { t.Parallel() resourceName := "outscale_ca.ca_test" diff --git a/outscale/resource_outscale_client_gateway_test.go b/outscale/resource_outscale_client_gateway_test.go index c0c96c29d..817758211 100644 --- a/outscale/resource_outscale_client_gateway_test.go +++ b/outscale/resource_outscale_client_gateway_test.go @@ -14,7 +14,7 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleClientGateway_basic(t *testing.T) { +func TestAccOthers_ClientGateway_basic(t *testing.T) { t.Parallel() resourceName := "outscale_client_gateway.foo" rBgpAsn := utils.RandIntRange(64512, 65534) @@ -52,7 +52,7 @@ func TestAccOutscaleClientGateway_basic(t *testing.T) { }) } -func TestAccOutscaleClientGateway_withTags(t *testing.T) { +func TestAccOthers_ClientGateway_withTags(t *testing.T) { resourceName := "outscale_client_gateway.foo" value := fmt.Sprintf("testacc-%s", acctest.RandString(5)) valueUpdated := fmt.Sprintf("testacc-%s", acctest.RandString(5)) diff --git a/outscale/resource_outscale_dhcp_option_test.go b/outscale/resource_outscale_dhcp_option_test.go index 74f70dd53..311688b92 100644 --- a/outscale/resource_outscale_dhcp_option_test.go +++ b/outscale/resource_outscale_dhcp_option_test.go @@ -17,7 +17,7 @@ import ( oscgo "github.com/outscale/osc-sdk-go/v2" ) -func TestAccOutscaleOAPIDhcpOptional_basic(t *testing.T) { +func TestAccOthers_DhcpOptional_basic(t *testing.T) { t.Parallel() resourceName := "outscale_dhcp_option.foo" value := fmt.Sprintf("test-acc-value-%s", acctest.RandString(5)) @@ -67,7 +67,7 @@ func TestAccOutscaleOAPIDhcpOptional_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIDhcpOptional_withEmptyAttrs(t *testing.T) { +func TestAccOthers_DhcpOptional_withEmptyAttrs(t *testing.T) { resourceName := "outscale_dhcp_option.foo" value := fmt.Sprintf("test-acc-value-%s", acctest.RandString(5)) @@ -116,18 +116,18 @@ func TestAccOutscaleOAPIDhcpOptional_withEmptyAttrs(t *testing.T) { }) } -func TestAccOutscaleOAPIDhcpOptional_withNet(t *testing.T) { +func TestAccNet_withDhcpOptional(t *testing.T) { t.Parallel() resourceName := "outscale_dhcp_option.outscale_dhcp_option" - - domainName := fmt.Sprintf("eu-west-2.compute%s.internal", acctest.RandString(3)) + domainName := fmt.Sprintf("%s.compute%s.internal", utils.GetRegion(), acctest.RandString(3)) domainServers := []string{"192.168.12.12", "192.168.12.132"} + tags := &oscgo.Tag{ Key: pointy.String(acctest.RandomWithPrefix("name")), Value: pointy.String(acctest.RandomWithPrefix("test-MZI")), } - domainNameUpdated := fmt.Sprintf("eu-west-2.compute%s.internal", acctest.RandString(3)) + domainNameUpdated := fmt.Sprintf("%s.compute%s.internal", utils.GetRegion(), acctest.RandString(3)) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -164,7 +164,7 @@ func TestAccOutscaleOAPIDhcpOptional_withNet(t *testing.T) { }) } -func TestAccOutscaleDHCPOption_importBasic(t *testing.T) { +func TestAccOthers_DHCPOption_importBasic(t *testing.T) { resourceName := "outscale_dhcp_option.foo" value := fmt.Sprintf("test-acc-value-%s", acctest.RandString(5)) diff --git a/outscale/resource_outscale_flexible_gpu_link_test.go b/outscale/resource_outscale_flexible_gpu_link_test.go index 03a572baf..54e15238f 100644 --- a/outscale/resource_outscale_flexible_gpu_link_test.go +++ b/outscale/resource_outscale_flexible_gpu_link_test.go @@ -6,11 +6,11 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIFlexibleGpuLink_basic(t *testing.T) { +func TestAccVM_withFlexibleGpuLink_basic(t *testing.T) { omi := os.Getenv("OUTSCALE_IMAGEID") - region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION")) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,7 +19,7 @@ func TestAccOutscaleOAPIFlexibleGpuLink_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIFlexibleGpuLinkConfig(omi, "tinav5.c2r2p1", region), + Config: testAccOutscaleOAPIFlexibleGpuLinkConfig(omi, "tinav5.c2r2p2", utils.GetRegion()), }, }, }) @@ -31,12 +31,14 @@ func testAccOutscaleOAPIFlexibleGpuLinkConfig(omi, vmType, region string) string image_id = "%s" vm_type = "%s" keypair_name = "terraform-basic" + placement_subregion_name = "%[3]sa" + } resource "outscale_flexible_gpu" "fGPU-1" { model_name = "nvidia-p6" generation = "v5" - subregion_name = "%s" + subregion_name = "%[3]sa" delete_on_vm_deletion = true } diff --git a/outscale/resource_outscale_flexible_gpu_test.go b/outscale/resource_outscale_flexible_gpu_test.go index 97fc01382..d7016b4e2 100644 --- a/outscale/resource_outscale_flexible_gpu_test.go +++ b/outscale/resource_outscale_flexible_gpu_test.go @@ -2,15 +2,14 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPIFlexibleGpu_basic(t *testing.T) { +func TestAccOthers_FlexibleGpu_basic(t *testing.T) { t.Parallel() - region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION")) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -19,7 +18,7 @@ func TestAccOutscaleOAPIFlexibleGpu_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIFlexibleGpuConfig(region), + Config: testAccOutscaleOAPIFlexibleGpuConfig(utils.GetRegion()), }, }, }) @@ -30,7 +29,7 @@ func testAccOutscaleOAPIFlexibleGpuConfig(region string) string { resource "outscale_flexible_gpu" "fGPU-1" { model_name = "nvidia-p6" generation = "v5" - subregion_name = "%s" + subregion_name = "%sa" delete_on_vm_deletion = true } diff --git a/outscale/resource_outscale_image_export_task_test.go b/outscale/resource_outscale_image_export_task_test.go index 3a6dd48cf..5aa84df40 100644 --- a/outscale/resource_outscale_image_export_task_test.go +++ b/outscale/resource_outscale_image_export_task_test.go @@ -6,14 +6,15 @@ import ( "testing" "github.com/hashicorp/terraform/helper/acctest" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIImageExportTask_basic(t *testing.T) { +func TestAccVM_withImageExportTask_basic(t *testing.T) { omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() imageName := acctest.RandomWithPrefix("test-image-name") tags := `tags { key = "test" diff --git a/outscale/resource_outscale_image_launch_permission_test.go b/outscale/resource_outscale_image_launch_permission_test.go index a87e65c2f..bb56df987 100644 --- a/outscale/resource_outscale_image_launch_permission_test.go +++ b/outscale/resource_outscale_image_launch_permission_test.go @@ -17,9 +17,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIImageLaunchPermission_Basic(t *testing.T) { +func TestAccNet_WithImageLaunchPermission_Basic(t *testing.T) { omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() accountID := os.Getenv("OUTSCALE_ACCOUNT") keypair := os.Getenv("OUTSCALE_KEYPAIR") sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") @@ -66,9 +66,9 @@ func TestAccOutscaleOAPIImageLaunchPermission_Basic(t *testing.T) { }) } -func TestAccOutscaleOAPIImageLaunchPermissionDestruction_Basic(t *testing.T) { +func TestAccNet_ImageLaunchPermissionDestruction_Basic(t *testing.T) { omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() accountID := os.Getenv("OUTSCALE_ACCOUNT") keypair := os.Getenv("OUTSCALE_KEYPAIR") sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") diff --git a/outscale/resource_outscale_image_test.go b/outscale/resource_outscale_image_test.go index a34f45ccd..1ec51e562 100644 --- a/outscale/resource_outscale_image_test.go +++ b/outscale/resource_outscale_image_test.go @@ -15,10 +15,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIImage_basic(t *testing.T) { +func TestAccOthers_Image_basic(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() var ami oscgo.Image rInt := acctest.RandInt() diff --git a/outscale/resource_outscale_internet_service_link_test.go b/outscale/resource_outscale_internet_service_link_test.go index 02d7bf1b6..afe46a240 100644 --- a/outscale/resource_outscale_internet_service_link_test.go +++ b/outscale/resource_outscale_internet_service_link_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIInternetServiceLink_basic(t *testing.T) { +func TestAccNet_WithInternetServiceLink_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -35,7 +35,7 @@ func TestAccOutscaleOAPIInternetServiceLink_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIInternetServiceLink_importBasic(t *testing.T) { +func TestAccNet_WithImportInternetServiceLink_Basic(t *testing.T) { resourceName := "outscale_internet_service_link.outscale_internet_service_link" resource.ParallelTest(t, resource.TestCase{ diff --git a/outscale/resource_outscale_internet_service_test.go b/outscale/resource_outscale_internet_service_test.go index 7e0de3e2f..c5a7388b1 100644 --- a/outscale/resource_outscale_internet_service_test.go +++ b/outscale/resource_outscale_internet_service_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIInternetService_basic(t *testing.T) { +func TestAccOthers_InternetService_basic(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/resource_outscale_keypair_test.go b/outscale/resource_outscale_keypair_test.go index 10079d830..1800ca16f 100644 --- a/outscale/resource_outscale_keypair_test.go +++ b/outscale/resource_outscale_keypair_test.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIKeyPair_basic(t *testing.T) { +func TestAccOthers_Keypair_basic(t *testing.T) { t.Parallel() var conf oscgo.Keypair @@ -37,7 +37,7 @@ func TestAccOutscaleOAPIKeyPair_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIKeyPair_retrieveName(t *testing.T) { +func TestAccOthers_Keypair_retrieveName(t *testing.T) { t.Parallel() var conf oscgo.Keypair @@ -60,7 +60,8 @@ func TestAccOutscaleOAPIKeyPair_retrieveName(t *testing.T) { }, }) } -func TestAccOutscaleOAPIKeyPair_generatedName(t *testing.T) { + +func TestAccOthers_Keypair_generatedName(t *testing.T) { t.Parallel() var conf oscgo.Keypair diff --git a/outscale/resource_outscale_load_balancer_attributes_test.go b/outscale/resource_outscale_load_balancer_attributes_test.go index d9e30292e..1f41b247c 100644 --- a/outscale/resource_outscale_load_balancer_attributes_test.go +++ b/outscale/resource_outscale_load_balancer_attributes_test.go @@ -5,13 +5,13 @@ import ( "testing" oscgo "github.com/outscale/osc-sdk-go/v2" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" - "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPILBUAttr_basic(t *testing.T) { +func TestAccOthers_LBUAttr_basic(t *testing.T) { t.Parallel() var conf oscgo.AccessLog @@ -25,7 +25,7 @@ func TestAccOutscaleOAPILBUAttr_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPILBUAttrConfig(r), + Config: testAccOutscaleOAPILBUAttrConfig(utils.GetRegion(), r), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPILBUAttrExists("outscale_load_balancer_attributes.bar2", &conf), )}, @@ -48,23 +48,21 @@ func testAccCheckOutscaleOAPILBUAttrExists(n string, res *oscgo.AccessLog) resou } } -func testAccOutscaleOAPILBUAttrConfig(r int) string { +func testAccOutscaleOAPILBUAttrConfig(region string, r int) string { return fmt.Sprintf(` resource "outscale_load_balancer" "bar" { - subregion_names = ["eu-west-2a"] - load_balancer_name = "foobar-terraform-elb-%d" + subregion_names = ["%sa"] + load_balancer_name = "foobar-terraform-elb-%d" listeners { - backend_port = 8000 - backend_protocol = "HTTP" - load_balancer_port = 80 + backend_port = 8000 + backend_protocol = "HTTP" + load_balancer_port = 80 load_balancer_protocol = "HTTP" } - - tags { - key = "test_baz" - value = "baz" - } - + tags { + key = "test_baz" + value = "baz" + } } resource "outscale_load_balancer_attributes" "bar2" { @@ -74,5 +72,5 @@ resource "outscale_load_balancer_attributes" "bar2" { } load_balancer_name = outscale_load_balancer.bar.id } -`, r) +`, region, r) } diff --git a/outscale/resource_outscale_load_balancer_policy_test.go b/outscale/resource_outscale_load_balancer_policy_test.go index c283bfd3a..0788c10d6 100644 --- a/outscale/resource_outscale_load_balancer_policy_test.go +++ b/outscale/resource_outscale_load_balancer_policy_test.go @@ -2,19 +2,18 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/acctest" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleCookieStickinessPolicy_basic(t *testing.T) { +func TestAccOthers_CookieStickinessPolicy_basic(t *testing.T) { t.Parallel() - lbName := fmt.Sprintf("tf-test-lb-%s", acctest.RandString(5)) - region := os.Getenv("OUTSCALE_REGION") - zone := fmt.Sprintf("%sa", region) + lbName := fmt.Sprintf("tf-test-lb-%s", acctest.RandString(10)) + zone := fmt.Sprintf("%sa", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -88,14 +87,14 @@ resource "outscale_load_balancer" "lb" { resource "outscale_load_balancer_policy" "app-policy" { policy_type = "app" policy_name = "foo-policy" - load_balancer_name = "${outscale_load_balancer.lb.id}" + load_balancer_name = outscale_load_balancer.lb.id cookie_name = "MyAppCookie" } resource "outscale_load_balancer_policy" "lb-policy" { policy_type = "load_balancer" policy_name = "lb-policy" - load_balancer_name = "${outscale_load_balancer.lb.id}" + load_balancer_name = outscale_load_balancer.lb.id cookie_expiration_period = 180 } `, rName, zone) @@ -118,14 +117,14 @@ resource "outscale_load_balancer" "lb" { resource "outscale_load_balancer_policy" "app-policy" { policy_type = "app" policy_name = "foo-policy" - load_balancer_name = "${outscale_load_balancer.lb.id}" + load_balancer_name = outscale_load_balancer.lb.id cookie_name = "MyOtherAppCookie" } resource "outscale_load_balancer_policy" "lb-policy" { policy_type = "load_balancer" policy_name = "lb-policy" - load_balancer_name = "${outscale_load_balancer.lb.id}" + load_balancer_name = outscale_load_balancer.lb.id cookie_expiration_period = 100 }`, rName, zone) } diff --git a/outscale/resource_outscale_load_balancer_test.go b/outscale/resource_outscale_load_balancer_test.go index 64819b27c..c15a74430 100644 --- a/outscale/resource_outscale_load_balancer_test.go +++ b/outscale/resource_outscale_load_balancer_test.go @@ -15,15 +15,13 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPILBUBasic(t *testing.T) { +func TestAccOthers_LBUBasic(t *testing.T) { t.Parallel() var conf oscgo.LoadBalancer resourceName := "outscale_load_balancer.bar" - r := utils.RandIntRange(0, 10) - region := os.Getenv("OUTSCALE_REGION") - zone := fmt.Sprintf("%sa", region) + zone := fmt.Sprintf("%sa", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { @@ -46,7 +44,7 @@ func TestAccOutscaleOAPILBUBasic(t *testing.T) { }) } -func TestAccOutscaleOAPILBUPublicIp(t *testing.T) { +func TestAccOthers_LBUPublicIp(t *testing.T) { t.Skip("will be done soon") t.Parallel() var conf oscgo.LoadBalancer @@ -200,7 +198,7 @@ resource "outscale_load_balancer" "bar" { } } -`, os.Getenv("OUTSCALE_REGION"), r) +`, utils.GetRegion(), r) } func testAccOutscaleOAPILBUPublicIpConfig(r int) string { diff --git a/outscale/resource_outscale_load_balancer_vms_test.go b/outscale/resource_outscale_load_balancer_vms_test.go index d6c406f78..5534b4988 100644 --- a/outscale/resource_outscale_load_balancer_vms_test.go +++ b/outscale/resource_outscale_load_balancer_vms_test.go @@ -7,15 +7,15 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" + "github.com/terraform-providers/terraform-provider-outscale/utils" oscgo "github.com/outscale/osc-sdk-go/v2" ) -func TestAccOutscaleOAPILBUAttachment_basic(t *testing.T) { +func TestAccVM_WithLBUAttachment_basic(t *testing.T) { t.Parallel() var conf oscgo.LoadBalancer omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") testCheckInstanceAttached := func(count int) resource.TestCheckFunc { return func(*terraform.State) error { @@ -36,7 +36,7 @@ func TestAccOutscaleOAPILBUAttachment_basic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPILBUDestroy, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPILBUAttachmentConfig1(omi, region), + Config: testAccOutscaleOAPILBUAttachmentConfig1(omi, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPILBUExists("outscale_load_balancer.bar", &conf), testCheckInstanceAttached(1), @@ -66,8 +66,8 @@ resource "outscale_vm" "foo1" { } resource "outscale_load_balancer_vms" "foo1" { - load_balancer_name = "${outscale_load_balancer.bar.id}" - backend_vm_ids = ["${outscale_vm.foo1.id}"] + load_balancer_name = outscale_load_balancer.bar.id + backend_vm_ids = [outscale_vm.foo1.id] } `, region, omi) } diff --git a/outscale/resource_outscale_nat_service_test.go b/outscale/resource_outscale_nat_service_test.go index 718dc4f2a..62da98a11 100644 --- a/outscale/resource_outscale_nat_service_test.go +++ b/outscale/resource_outscale_nat_service_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPINatService_basic(t *testing.T) { +func TestAccNet_WithNatService_basic(t *testing.T) { var natService oscgo.NatService resource.Test(t, resource.TestCase{ @@ -31,7 +31,7 @@ func TestAccOutscaleOAPINatService_basic(t *testing.T) { }) } -func TestAccOutscaleOAPINatService_basicWithDataSource(t *testing.T) { +func TestAccNet_NatService_basicWithDataSource(t *testing.T) { var natService oscgo.NatService resource.Test(t, resource.TestCase{ @@ -126,7 +126,7 @@ const testAccOAPINatGatewayConfig = ` } resource "outscale_subnet" "outscale_subnet" { - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id ip_range = "10.0.0.0/18" } @@ -134,8 +134,8 @@ const testAccOAPINatGatewayConfig = ` resource "outscale_nat_service" "outscale_nat_service" { depends_on = ["outscale_route.outscale_route"] - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" - public_ip_id = "${outscale_public_ip.outscale_public_ip.public_ip_id}" + subnet_id = outscale_subnet.outscale_subnet.subnet_id + public_ip_id = outscale_public_ip.outscale_public_ip.public_ip_id } resource "outscale_route_table" "outscale_route_table" { diff --git a/outscale/resource_outscale_net_access_point_test.go b/outscale/resource_outscale_net_access_point_test.go index 1853117a9..ba4f9f63f 100644 --- a/outscale/resource_outscale_net_access_point_test.go +++ b/outscale/resource_outscale_net_access_point_test.go @@ -2,14 +2,14 @@ package outscale import ( "fmt" - "os" "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPINetAccessPoint_basic(t *testing.T) { - ServiceName := fmt.Sprintf("com.outscale.%s.api", os.Getenv("OUTSCALE_REGION")) +func TestAccNet_AccessPoint_basic(t *testing.T) { + ServiceName := fmt.Sprintf("com.outscale.%s.api", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { diff --git a/outscale/resource_outscale_net_attributes_test.go b/outscale/resource_outscale_net_attributes_test.go index 049b184f1..6d2a9e08d 100644 --- a/outscale/resource_outscale_net_attributes_test.go +++ b/outscale/resource_outscale_net_attributes_test.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPILinAttr_basic(t *testing.T) { +func TestAccNet_Attributes_basic(t *testing.T) { resourceName := "outscale_net_attributes.outscale_net_attributes" resource.Test(t, resource.TestCase{ @@ -25,7 +25,7 @@ func TestAccOutscaleOAPILinAttr_basic(t *testing.T) { }) } -func TestAccOutscaleOAPILinAttr_withoutDHCPID(t *testing.T) { +func TestAccNet_Attributes_withoutDHCPID(t *testing.T) { resourceName := "outscale_net_attributes.outscale_net_attributes" resource.Test(t, resource.TestCase{ diff --git a/outscale/resource_outscale_net_peering_acceptation_test.go b/outscale/resource_outscale_net_peering_acceptation_test.go index 90444e631..05818862d 100644 --- a/outscale/resource_outscale_net_peering_acceptation_test.go +++ b/outscale/resource_outscale_net_peering_acceptation_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPILinPeeringConnectionAccepter_sameAccount(t *testing.T) { +func TestAccNet_PeeringConnectionAccepter_sameAccount(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, Providers: testAccProviders, @@ -63,8 +63,8 @@ const testAccOutscaleOAPILinPeeringConnectionAccepterSameAccountConfig = ` } resource "outscale_net_peering" "foo" { - source_net_id = "${outscale_net.foo.id}" - accepter_net_id = "${outscale_net.bar.id}" + source_net_id = outscale_net.foo.id + accepter_net_id = outscale_net.bar.id tags { key = "Side" @@ -74,6 +74,6 @@ const testAccOutscaleOAPILinPeeringConnectionAccepterSameAccountConfig = ` // Accepter's side of the connection. resource "outscale_net_peering_acceptation" "peer" { - net_peering_id = "${outscale_net_peering.foo.id}" + net_peering_id = outscale_net_peering.foo.id } ` diff --git a/outscale/resource_outscale_net_peering_test.go b/outscale/resource_outscale_net_peering_test.go index dc33dd7d8..4de1c2f5f 100644 --- a/outscale/resource_outscale_net_peering_test.go +++ b/outscale/resource_outscale_net_peering_test.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPILinPeeringConnection_basic(t *testing.T) { +func TestAccNet_PeeringConnection_basic(t *testing.T) { var connection oscgo.NetPeering resource.Test(t, resource.TestCase{ @@ -35,7 +35,7 @@ func TestAccOutscaleOAPILinPeeringConnection_basic(t *testing.T) { }) } -func TestAccOutscaleOAPILinPeeringConnection_importBasic(t *testing.T) { +func TestAccNet_PeeringConnection_importBasic(t *testing.T) { resourceName := "outscale_net_peering.foo" resource.ParallelTest(t, resource.TestCase{ @@ -67,7 +67,7 @@ func testAccCheckOutscaleOAPILinkPeeeringConnectionImportStateIDFunc(resourceNam } } -func TestAccOutscaleOAPILinPeeringConnection_plan(t *testing.T) { +func TestAccNet_PeeringConnection_plan(t *testing.T) { var connection oscgo.NetPeering // reach out and DELETE the VPC Peering connection outside of Terraform @@ -228,7 +228,7 @@ const testAccOAPIVpcPeeringConfig = ` } resource "outscale_net_peering" "foo" { - source_net_id = "${outscale_net.foo.id}" - accepter_net_id = "${outscale_net.bar.id}" + source_net_id = outscale_net.foo.id + accepter_net_id = outscale_net.bar.id } ` diff --git a/outscale/resource_outscale_net_test.go b/outscale/resource_outscale_net_test.go index b6a091a9e..24a0c9b06 100644 --- a/outscale/resource_outscale_net_test.go +++ b/outscale/resource_outscale_net_test.go @@ -13,8 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPILin_basic(t *testing.T) { - t.Parallel() +func TestAccNet_basic(t *testing.T) { var conf1 oscgo.Net var conf2 oscgo.Net @@ -38,7 +37,7 @@ func TestAccOutscaleOAPILin_basic(t *testing.T) { }) } -func TestAccOutscaleOAPILin_UpdateTags(t *testing.T) { +func TestAccNet_UpdateTags(t *testing.T) { t.Parallel() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, diff --git a/outscale/resource_outscale_nic_link_test.go b/outscale/resource_outscale_nic_link_test.go index 216f80cb4..56525d554 100644 --- a/outscale/resource_outscale_nic_link_test.go +++ b/outscale/resource_outscale_nic_link_test.go @@ -18,10 +18,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleNicLink_Basic(t *testing.T) { +func TestAccNet_withNicLink_Basic(t *testing.T) { var conf oscgo.Nic omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() rInt := acctest.RandInt() resource.Test(t, resource.TestCase{ @@ -46,10 +46,10 @@ func TestAccOutscaleNicLink_Basic(t *testing.T) { }) } -func TestAccOutscaleNicLink_importBasic(t *testing.T) { +func TestAccNet_ImportNicLink_Basic(t *testing.T) { resourceName := "outscale_nic_link.outscale_nic_link" omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() rInt := acctest.RandInt() resource.ParallelTest(t, resource.TestCase{ diff --git a/outscale/resource_outscale_nic_private_ip_test.go b/outscale/resource_outscale_nic_private_ip_test.go index 42f25abf7..492f55905 100644 --- a/outscale/resource_outscale_nic_private_ip_test.go +++ b/outscale/resource_outscale_nic_private_ip_test.go @@ -2,16 +2,15 @@ package outscale import ( "fmt" - "os" "testing" oscgo "github.com/outscale/osc-sdk-go/v2" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" ) -func TestAccOutscaleOAPINetworkInterfacePrivateIPBasic(t *testing.T) { - region := os.Getenv("OUTSCALE_REGION") +func TestAccNet_NICPrivateIPBasic(t *testing.T) { var conf oscgo.Nic resource.Test(t, resource.TestCase{ @@ -21,7 +20,7 @@ func TestAccOutscaleOAPINetworkInterfacePrivateIPBasic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIENIDestroy, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPINetworkInterfacePrivateIPConfigBasic(region), + Config: testAccOutscaleOAPINetworkInterfacePrivateIPConfigBasic(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIENIExists("outscale_nic.outscale_nic", &conf), resource.TestCheckResourceAttr("outscale_nic_private_ip.outscale_nic_private_ip", "private_ips.#", "1"), @@ -32,8 +31,7 @@ func TestAccOutscaleOAPINetworkInterfacePrivateIPBasic(t *testing.T) { }) } -func TestAccOutscaleOAPINetworkInterfacePrivateIP_importBasic(t *testing.T) { - region := os.Getenv("OUTSCALE_REGION") +func TestAccNet_Import_NIC_PrivateIP_Basic(t *testing.T) { resourceName := "outscale_nic_private_ip.outscale_nic_private_ip" resource.Test(t, resource.TestCase{ @@ -43,7 +41,7 @@ func TestAccOutscaleOAPINetworkInterfacePrivateIP_importBasic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIENIDestroy, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPINetworkInterfacePrivateIPConfigBasic(region), + Config: testAccOutscaleOAPINetworkInterfacePrivateIPConfigBasic(utils.GetRegion()), }, { ResourceName: resourceName, diff --git a/outscale/resource_outscale_nic_test.go b/outscale/resource_outscale_nic_test.go index 468e75a39..ecd92e06a 100644 --- a/outscale/resource_outscale_nic_test.go +++ b/outscale/resource_outscale_nic_test.go @@ -3,7 +3,6 @@ package outscale import ( "context" "fmt" - "os" "reflect" "testing" "time" @@ -15,10 +14,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIENI_basic(t *testing.T) { - t.Parallel() +func TestAccNet_WithNic_basic(t *testing.T) { var conf oscgo.Nic - subregion := os.Getenv("OUTSCALE_REGION") + subregion := utils.GetRegion() resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -118,18 +116,18 @@ func testAccOutscaleOAPIENIConfig(subregion string) string { resource "outscale_subnet" "outscale_subnet" { subregion_name = "%sa" ip_range = "10.0.0.0/16" - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id } resource "outscale_security_group" "outscale_sg" { description = "sg for terraform tests" security_group_name = "terraform-sg" - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id } resource "outscale_nic" "outscale_nic" { - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" - security_group_ids = ["${outscale_security_group.outscale_sg.security_group_id}"] + subnet_id = outscale_subnet.outscale_subnet.subnet_id + security_group_ids = [outscale_security_group.outscale_sg.security_group_id] private_ips { is_primary = true @@ -156,19 +154,19 @@ func testAccOutscaleOAPIENIConfigUpdate(subregion string) string { resource "outscale_subnet" "outscale_subnet" { subregion_name = "%sa" - ip_range = "10.0.0.0/16" - net_id = "${outscale_net.outscale_net.net_id}" + ip_range = "10.0.0.0/24" + net_id = outscale_net.outscale_net.net_id } resource "outscale_security_group" "outscale_sg" { description = "sg for terraform tests" security_group_name = "terraform-sg" - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id } resource "outscale_nic" "outscale_nic" { - subnet_id = "${outscale_subnet.outscale_subnet.subnet_id}" - security_group_ids = ["${outscale_security_group.outscale_sg.security_group_id}"] + subnet_id = outscale_subnet.outscale_subnet.subnet_id + security_group_ids = [outscale_security_group.outscale_sg.security_group_id] private_ips { is_primary = true diff --git a/outscale/resource_outscale_public_ip_link_test.go b/outscale/resource_outscale_public_ip_link_test.go index 6d450c3e7..38293b2e5 100644 --- a/outscale/resource_outscale_public_ip_link_test.go +++ b/outscale/resource_outscale_public_ip_link_test.go @@ -17,10 +17,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIPublicIPLink_basic(t *testing.T) { +func TestAccNet_WithPublicIPLink_basic(t *testing.T) { var a oscgo.PublicIp omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") @@ -30,7 +29,7 @@ func TestAccOutscaleOAPIPublicIPLink_basic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIPublicIPLinkDestroy, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIPublicIPLinkConfig(omi, "tinav4.c2r2p2", region, keypair, sgId), + Config: testAccOutscaleOAPIPublicIPLinkConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), keypair, sgId), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIPublicIPLExists( "outscale_public_ip.ip", &a), diff --git a/outscale/resource_outscale_public_ip_test.go b/outscale/resource_outscale_public_ip_test.go index 86d36aa6b..77ada4b67 100644 --- a/outscale/resource_outscale_public_ip_test.go +++ b/outscale/resource_outscale_public_ip_test.go @@ -9,12 +9,13 @@ import ( "time" oscgo "github.com/outscale/osc-sdk-go/v2" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIPublicIP_basic(t *testing.T) { +func TestAccOthers_PublicIP_basic(t *testing.T) { t.Parallel() var conf oscgo.PublicIp @@ -35,11 +36,11 @@ func TestAccOutscaleOAPIPublicIP_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIPublicIP_instance(t *testing.T) { +func TestAccNet_PublicIP_instance(t *testing.T) { t.Parallel() var conf oscgo.PublicIp omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() keypair := os.Getenv("OUTSCALE_KEYPAIR") sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") @@ -71,10 +72,10 @@ func TestAccOutscaleOAPIPublicIP_instance(t *testing.T) { // // This test is an expansion of TestAccOutscalePublicIP_instance, by testing the // // associated Private PublicIPs of two instances -func TestAccOutscaleOAPIPublicIP_associated_user_private_ip(t *testing.T) { +func TestAccNet_PublicIP_associated_user_private_ip(t *testing.T) { var one oscgo.PublicIp omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() keypair := os.Getenv("OUTSCALE_KEYPAIR") sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") @@ -317,7 +318,7 @@ func testAccOutscaleOAPIPublicIPInstanceConfig2(omi, vmType, region, keypair, sg value = "tf-acc-test" } - net_id = "${outscale_net.net.id}" + net_id = outscale_net.net.id } resource "outscale_vm" "basic" { @@ -352,7 +353,7 @@ func testAccOutscaleOAPIPublicIPInstanceConfigAssociated(omi, vmType, region, ke value = "tf-acc-test" } - net_id = "${outscale_net.net.id}" + net_id = outscale_net.net.id } resource "outscale_vm" "basic" { @@ -395,7 +396,7 @@ func testAccOutscaleOAPIPublicIPInstanceConfigAssociatedSwitch(omi, vmType, regi value = "tf-acc-test" } - net_id = "${outscale_net.net.id}" + net_id = outscale_net.net.id } resource "outscale_vm" "basic" { diff --git a/outscale/resource_outscale_route_table_link_test.go b/outscale/resource_outscale_route_table_link_test.go index 4ad202b43..1ce60de2d 100644 --- a/outscale/resource_outscale_route_table_link_test.go +++ b/outscale/resource_outscale_route_table_link_test.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPILinkRouteTable_basic(t *testing.T) { +func TestAccNet_WithLinkRouteTable_basic(t *testing.T) { t.Parallel() var v oscgo.RouteTable resource.Test(t, resource.TestCase{ @@ -37,7 +37,7 @@ func TestAccOutscaleOAPILinkRouteTable_basic(t *testing.T) { }) } -func TestAccResourceOAPILinkRouteTable_importBasic(t *testing.T) { +func TestAccNet_ImportLinkRouteTable_Basic(t *testing.T) { resourceName := "outscale_route_table_link.foo" resource.ParallelTest(t, resource.TestCase{ diff --git a/outscale/resource_outscale_route_table_test.go b/outscale/resource_outscale_route_table_test.go index 1fd4ccdd7..d39bf54bf 100644 --- a/outscale/resource_outscale_route_table_test.go +++ b/outscale/resource_outscale_route_table_test.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIRouteTable_basic(t *testing.T) { +func TestAccNet_WithRouteTable_basic(t *testing.T) { var v oscgo.RouteTable testCheck := func(*terraform.State) error { @@ -76,9 +76,8 @@ func TestAccOutscaleOAPIRouteTable_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIRouteTable_instance(t *testing.T) { +func TestAccNet_RouteTable_instance(t *testing.T) { omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") var v oscgo.RouteTable @@ -105,7 +104,7 @@ func TestAccOutscaleOAPIRouteTable_instance(t *testing.T) { CheckDestroy: testAccCheckOAPIRouteTableDestroy, Steps: []resource.TestStep{ { - Config: testAccOAPIRouteTableConfigInstance(omi, "tinav4.c2r2p2", region), + Config: testAccOAPIRouteTableConfigInstance(omi, "tinav4.c2r2p2", utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOAPIRouteTableExists( "outscale_route_table.foo", &v, nil), @@ -116,7 +115,7 @@ func TestAccOutscaleOAPIRouteTable_instance(t *testing.T) { }) } -func TestAccOutscaleOAPIRouteTable_tags(t *testing.T) { +func TestAccNet_WithRouteTable_tags(t *testing.T) { value1 := ` tags { key = "name" @@ -163,7 +162,7 @@ func TestAccOutscaleOAPIRouteTable_tags(t *testing.T) { }) } -func TestAccOutscaleRouteTable_importBasic(t *testing.T) { +func TestAccNet_RouteTable_importBasic(t *testing.T) { resourceName := "outscale_route_table.foo" resource.ParallelTest(t, resource.TestCase{ diff --git a/outscale/resource_outscale_route_test.go b/outscale/resource_outscale_route_test.go index f82a24365..ebebe6ce5 100644 --- a/outscale/resource_outscale_route_test.go +++ b/outscale/resource_outscale_route_test.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIRoute_noopdiff(t *testing.T) { +func TestAccNet_OutscaleOAPIRoute_noopdiff(t *testing.T) { var route oscgo.Route resource.Test(t, resource.TestCase{ @@ -39,7 +39,7 @@ func TestAccOutscaleOAPIRoute_noopdiff(t *testing.T) { }) } -func TestAccOutscaleOAPIRoute_importBasic(t *testing.T) { +func TestAccNet_ImportRoute_Basic(t *testing.T) { resourceName := "outscale_route.test" @@ -62,7 +62,7 @@ func TestAccOutscaleOAPIRoute_importBasic(t *testing.T) { }) } -func TestAccOutscaleOAPIRoute_importWithNatService(t *testing.T) { +func TestAccNet_Route_importWithNatService(t *testing.T) { resourceName := "outscale_route.outscale_route_nat" resource.ParallelTest(t, resource.TestCase{ @@ -84,7 +84,7 @@ func TestAccOutscaleOAPIRoute_importWithNatService(t *testing.T) { }) } -func TestAccOutscaleOAPIRoute_changeTarget(t *testing.T) { +func TestAccNet_Route_changeTarget(t *testing.T) { var route oscgo.Route resource.Test(t, resource.TestCase{ @@ -111,7 +111,7 @@ func TestAccOutscaleOAPIRoute_changeTarget(t *testing.T) { }) } -func TestAccOutscaleOAPIRoute_onlyOneTarget(t *testing.T) { +func TestAccNet_Route_onlyOneTarget(t *testing.T) { regex := regexp.MustCompile(".*") resource.Test(t, resource.TestCase{ Providers: testAccProviders, diff --git a/outscale/resource_outscale_security_group_rule_test.go b/outscale/resource_outscale_security_group_rule_test.go index a487bef76..c2d94f975 100644 --- a/outscale/resource_outscale_security_group_rule_test.go +++ b/outscale/resource_outscale_security_group_rule_test.go @@ -16,7 +16,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleSecurityGroupRule_basic(t *testing.T) { +func TestAccOthers_SecurityGroupRule_basic(t *testing.T) { t.Parallel() resourceName := "outscale_security_group_rule.outscale_security_group_rule_https" @@ -50,7 +50,7 @@ func TestAccOutscaleSecurityGroupRule_basic(t *testing.T) { } } -func TestAccOutscaleSecurityGroupRule_withSecurityGroupMember(t *testing.T) { +func TestAccOthers_SecurityGroupRule_withSecurityGroupMember(t *testing.T) { t.Parallel() rInt := acctest.RandInt() accountID := os.Getenv("OUTSCALE_ACCOUNT") diff --git a/outscale/resource_outscale_security_group_test.go b/outscale/resource_outscale_security_group_test.go index dd4452549..73fdeaaa2 100644 --- a/outscale/resource_outscale_security_group_test.go +++ b/outscale/resource_outscale_security_group_test.go @@ -11,7 +11,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPISecurityGroup(t *testing.T) { +func TestAccNet_WithSecurityGroup(t *testing.T) { var group oscgo.SecurityGroup rInt := acctest.RandInt() @@ -89,7 +89,7 @@ func testAccOutscaleOAPISecurityGroupConfig(rInt int) string { value = "tf-acc-test" } - net_id = "${outscale_net.net.id}" + net_id = outscale_net.net.id } `, rInt) } diff --git a/outscale/resource_outscale_server_certificate_test.go b/outscale/resource_outscale_server_certificate_test.go index ef17a7e99..f153dab6a 100644 --- a/outscale/resource_outscale_server_certificate_test.go +++ b/outscale/resource_outscale_server_certificate_test.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIServerCertificate_basic(t *testing.T) { +func TestAccOthers_ServerCertificate_basic(t *testing.T) { t.Parallel() resourceName := "outscale_server_certificate.test" rName := acctest.RandomWithPrefix("acc-test") diff --git a/outscale/resource_outscale_snapshot_attributes_test.go b/outscale/resource_outscale_snapshot_attributes_test.go index 51cbcfa3b..1ce168180 100644 --- a/outscale/resource_outscale_snapshot_attributes_test.go +++ b/outscale/resource_outscale_snapshot_attributes_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) func TestAccOutscaleOAPISnapshotAttributes_Basic(t *testing.T) { @@ -18,13 +19,13 @@ func TestAccOutscaleOAPISnapshotAttributes_Basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotAttributesConfig(true, false, accountID), + Config: testAccOutscaleOAPISnapshotAttributesConfig(true, false, accountID, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testCheckResourceGetAttr("outscale_snapshot.test", "id", &snapshotID), ), }, { - Config: testAccOutscaleOAPISnapshotAttributesConfig(true, true, accountID), + Config: testAccOutscaleOAPISnapshotAttributesConfig(true, true, accountID, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testCheckResourceGetAttr("outscale_snapshot.test", "id", &snapshotID), ), @@ -33,10 +34,10 @@ func TestAccOutscaleOAPISnapshotAttributes_Basic(t *testing.T) { }) } -func testAccOutscaleOAPISnapshotAttributesConfig(includeAddition, includeRemoval bool, aid string) string { +func testAccOutscaleOAPISnapshotAttributesConfig(includeAddition, includeRemoval bool, aid, region string) string { base := fmt.Sprintf(` resource "outscale_volume" "description_test" { - subregion_name = "eu-west-2a" + subregion_name = "%[2]sa" size = 1 } @@ -49,10 +50,10 @@ func testAccOutscaleOAPISnapshotAttributesConfig(includeAddition, includeRemoval snapshot_id = "${outscale_snapshot.test.id}" permissions_to_create_volume_removals { - account_ids = ["%s"] + account_ids = ["%[1]s"] } } - `, aid) + `, aid, region) if includeAddition { return base + fmt.Sprintf(` diff --git a/outscale/resource_outscale_snapshot_export_task_test.go b/outscale/resource_outscale_snapshot_export_task_test.go index 30b712557..6af4a48fe 100644 --- a/outscale/resource_outscale_snapshot_export_task_test.go +++ b/outscale/resource_outscale_snapshot_export_task_test.go @@ -7,9 +7,10 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/hashicorp/terraform/helper/acctest" + "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPISnapshotExportTask_basic(t *testing.T) { +func TestAccOthers_SnapshotExportTask_basic(t *testing.T) { osuBucketNames := []string{ acctest.RandomWithPrefix("terraform-export-bucket-"), acctest.RandomWithPrefix("terraform-export-bucket-"), @@ -29,13 +30,13 @@ func TestAccOutscaleOAPISnapshotExportTask_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotExportTaskConfig("", osuBucketNames[0]), + Config: testAccOutscaleOAPISnapshotExportTaskConfig("", osuBucketNames[0], utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISnapshotExportTaskExists("outscale_snapshot_export_task.outscale_snapshot_export_task"), ), }, { - Config: testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketNames[1]), + Config: testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketNames[1], utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISnapshotExportTaskExists("outscale_snapshot_export_task.outscale_snapshot_export_task"), ), @@ -59,10 +60,10 @@ func testAccCheckOutscaleOAPISnapshotExportTaskExists(n string) resource.TestChe } } -func testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketName string) string { +func testAccOutscaleOAPISnapshotExportTaskConfig(tags, osuBucketName, region string) string { return fmt.Sprintf(` resource "outscale_volume" "outscale_volume_snap" { - subregion_name = "eu-west-2a" + subregion_name = "%[3]sa" size = 10 } resource "outscale_snapshot" "outscale_snapshot" { @@ -77,5 +78,5 @@ resource "outscale_snapshot_export_task" "outscale_snapshot_export_task" { } %[1]s } - `, tags, osuBucketName) + `, tags, osuBucketName, region) } diff --git a/outscale/resource_outscale_snapshot_test.go b/outscale/resource_outscale_snapshot_test.go index 585930aa0..c0209e4d6 100644 --- a/outscale/resource_outscale_snapshot_test.go +++ b/outscale/resource_outscale_snapshot_test.go @@ -3,7 +3,6 @@ package outscale import ( "context" "fmt" - "os" "testing" "time" @@ -14,9 +13,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPISnapshot_basic(t *testing.T) { +func TestAccOthers_Snapshot_basic(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") var v oscgo.Snapshot resource.Test(t, resource.TestCase{ @@ -24,7 +22,7 @@ func TestAccOutscaleOAPISnapshot_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotConfig(region), + Config: testAccOutscaleOAPISnapshotConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOAPISnapshotExists("outscale_snapshot.outscale_snapshot", &v), ), @@ -33,9 +31,8 @@ func TestAccOutscaleOAPISnapshot_basic(t *testing.T) { }) } -func TestAccOutscaleOAPISnapshot_withDescription(t *testing.T) { +func TestAccOthers_Snapshot_withDescription(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") var v oscgo.Snapshot resource.Test(t, resource.TestCase{ @@ -43,7 +40,7 @@ func TestAccOutscaleOAPISnapshot_withDescription(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotConfigWithDescription(region), + Config: testAccOutscaleOAPISnapshotConfigWithDescription(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOAPISnapshotExists("outscale_snapshot.test", &v), resource.TestCheckResourceAttr("outscale_snapshot.test", "description", "Snapshot Acceptance Test"), @@ -53,9 +50,8 @@ func TestAccOutscaleOAPISnapshot_withDescription(t *testing.T) { }) } -func TestAccOutscaleOAPISnapshot_CopySnapshot(t *testing.T) { +func TestAccOthers_Snapshot_CopySnapshot(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") var v oscgo.Snapshot resource.Test(t, resource.TestCase{ @@ -63,7 +59,7 @@ func TestAccOutscaleOAPISnapshot_CopySnapshot(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotConfigCopySnapshot(region), + Config: testAccOutscaleOAPISnapshotConfigCopySnapshot(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOAPISnapshotExists("outscale_snapshot.test", &v), resource.TestCheckResourceAttr("outscale_snapshot.test", "description", "Target Snapshot Acceptance Test"), @@ -73,9 +69,10 @@ func TestAccOutscaleOAPISnapshot_CopySnapshot(t *testing.T) { }) } -func TestAccOutscaleOAPISnapshot_UpdateTags(t *testing.T) { - region := os.Getenv("OUTSCALE_REGION") +func TestAccOthers_Snapshot_UpdateTags(t *testing.T) { + t.Parallel() + region := utils.GetRegion() //var v oscgo.Snapshot resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -93,8 +90,8 @@ func TestAccOutscaleOAPISnapshot_UpdateTags(t *testing.T) { }) } -func TestAccOutscaleOAPISnapshot_importBasic(t *testing.T) { - region := os.Getenv("OUTSCALE_REGION") +func TestAccOthers_Snapshot_importBasic(t *testing.T) { + t.Parallel() var v oscgo.Snapshot resource.Test(t, resource.TestCase{ @@ -102,7 +99,7 @@ func TestAccOutscaleOAPISnapshot_importBasic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISnapshotConfig(region), + Config: testAccOutscaleOAPISnapshotConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOAPISnapshotExists("outscale_snapshot.outscale_snapshot", &v), ), @@ -181,7 +178,7 @@ func testAccOutscaleOAPISnapshotConfigWithDescription(region string) string { } resource "outscale_snapshot" "test" { - volume_id = "${outscale_volume.description_test.id}" + volume_id = outscale_volume.description_test.id description = "Snapshot Acceptance Test" } `, region) @@ -195,13 +192,13 @@ func testAccOutscaleOAPISnapshotConfigCopySnapshot(region string) string { } resource "outscale_snapshot" "source" { - volume_id = "${outscale_volume.description_test.id}" + volume_id = outscale_volume.description_test.id description = "Source Snapshot Acceptance Test" } resource "outscale_snapshot" "test" { source_region_name = "%[1]s" - source_snapshot_id = "${outscale_snapshot.source.id}" + source_snapshot_id = outscale_snapshot.source.id description = "Target Snapshot Acceptance Test" } `, region) @@ -214,8 +211,8 @@ func testAccOutscaleOAPISnapshotConfigUpdateTags(region, value string) string { size = 10 } resource "outscale_snapshot" "outscale_snapshot" { - volume_id = "${outscale_volume.outscale_volume.volume_id}" - + volume_id = outscale_volume.outscale_volume.volume_id + tags { key = "Name" value = "%s" diff --git a/outscale/resource_outscale_subnet_test.go b/outscale/resource_outscale_subnet_test.go index e25d90250..83bfe6ebc 100644 --- a/outscale/resource_outscale_subnet_test.go +++ b/outscale/resource_outscale_subnet_test.go @@ -3,7 +3,6 @@ package outscale import ( "context" "fmt" - "os" "strings" "testing" "time" @@ -14,10 +13,9 @@ import ( "github.com/terraform-providers/terraform-provider-outscale/utils" ) -func TestAccOutscaleOAPISubNet_basic(t *testing.T) { +func TestAccNet_WithSubNet_basic(t *testing.T) { t.Parallel() var conf oscgo.Subnet - region := os.Getenv("OUTSCALE_REGION") resourceName := "outscale_subnet.subnet" @@ -27,14 +25,14 @@ func TestAccOutscaleOAPISubNet_basic(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPISubNetDestroyed, // we need to create the destroyed test case Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPISubnetConfig(region, false), + Config: testAccOutscaleOAPISubnetConfig(utils.GetRegion(), false), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISubNetExists(resourceName, &conf), resource.TestCheckResourceAttr(resourceName, "map_public_ip_on_launch", "false"), ), }, { - Config: testAccOutscaleOAPISubnetConfig(region, true), + Config: testAccOutscaleOAPISubnetConfig(utils.GetRegion(), true), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPISubNetExists(resourceName, &conf), resource.TestCheckResourceAttr(resourceName, "map_public_ip_on_launch", "true"), @@ -136,9 +134,9 @@ func testAccOutscaleOAPISubnetConfig(region string, mapPublicIpOnLaunch bool) st } resource "outscale_subnet" "subnet" { - ip_range = "10.0.0.0/16" - subregion_name = "%sa" - net_id = "${outscale_net.net.id}" + ip_range = "10.0.0.0/24" + subregion_name = "%sb" + net_id = outscale_net.net.id map_public_ip_on_launch = %v tags { key = "name" diff --git a/outscale/resource_outscale_tags_test.go b/outscale/resource_outscale_tags_test.go index 38fa71ada..080039f1d 100644 --- a/outscale/resource_outscale_tags_test.go +++ b/outscale/resource_outscale_tags_test.go @@ -18,10 +18,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIVM_tags(t *testing.T) { +func TestAccVM_tags(t *testing.T) { v := &oscgo.Vm{} omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") if os.Getenv("TEST_QUOTA") == "true" { resource.Test(t, resource.TestCase{ @@ -30,7 +29,7 @@ func TestAccOutscaleOAPIVM_tags(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckOAPIInstanceConfigTags(omi, "tinav4.c2r2p2", region, "keyOriginal", "valueOriginal"), + Config: testAccCheckOAPIInstanceConfigTags(omi, "tinav4.c2r2p2", utils.GetRegion(), "keyOriginal", "valueOriginal"), Check: resource.ComposeTestCheckFunc( oapiTestAccCheckOutscaleVMExists("outscale_vm.vm", v), testAccCheckOAPIVMTags(v, "keyOriginal", "valueOriginal"), @@ -40,7 +39,7 @@ func TestAccOutscaleOAPIVM_tags(t *testing.T) { ), }, { - Config: testAccCheckOAPIInstanceConfigTags(omi, "tinav4.c2r2p2", region, "keyUpdated", "valueUpdated"), + Config: testAccCheckOAPIInstanceConfigTags(omi, "tinav4.c2r2p2", utils.GetRegion(), "keyUpdated", "valueUpdated"), Check: resource.ComposeTestCheckFunc( oapiTestAccCheckOutscaleVMExists("outscale_vm.vm", v), testAccCheckOAPIVMTags(v, "keyUpdated", "valueUpdated"), @@ -149,27 +148,11 @@ func checkOAPITags(ts []oscgo.ResourceTag, key, value string) error { func testAccCheckOAPIInstanceConfigTags(omi, vmType, region, key, value string) string { return fmt.Sprintf(` - resource "outscale_net" "outscale_net" { - ip_range = "10.0.0.0/16" - - tags { - key = "Name" - value = "testacc-tags-rs" - } - } - - 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" - } resource "outscale_vm" "vm" { image_id = "%s" vm_type = "%s" keypair_name = "terraform-basic" - placement_subregion_name = "%sa" - subnet_id = outscale_subnet.outscale_subnet.subnet_id - private_ips = ["10.0.0.12"] + placement_subregion_name = "%[3]sa" } resource "outscale_tag" "foo" { diff --git a/outscale/resource_outscale_virtual_gateway_link_test.go b/outscale/resource_outscale_virtual_gateway_link_test.go index 8ef3cac48..e93f39095 100644 --- a/outscale/resource_outscale_virtual_gateway_link_test.go +++ b/outscale/resource_outscale_virtual_gateway_link_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIVpnGatewayAttachment_basic(t *testing.T) { +func TestAccNet_withpnGatewayAttachment_basic(t *testing.T) { var vpc oscgo.Net var vgw oscgo.VirtualGateway t.Parallel() @@ -39,7 +39,7 @@ func TestAccOutscaleOAPIVpnGatewayAttachment_basic(t *testing.T) { }) } -func TestAccResourceVpnGatewayAttachment_importBasic(t *testing.T) { +func TestAccNet_VpnGatewayAttachment_importBasic(t *testing.T) { resourceName := "outscale_virtual_gateway_link.test" resource.ParallelTest(t, resource.TestCase{ @@ -71,7 +71,7 @@ func testAccCheckVpnGatewayAttachmentImportStateIDFunc(resourceName string) reso } } -func TestAccAWSOAPIVpnGatewayAttachment_deleted(t *testing.T) { +func TestAccNet_WithVpnGatewayAttachment_deleted(t *testing.T) { t.Parallel() var vgw oscgo.VirtualGateway var vpc oscgo.Net diff --git a/outscale/resource_outscale_virtual_gateway_route_propagation_test.go b/outscale/resource_outscale_virtual_gateway_route_propagation_test.go index 237067bfd..391b1ad03 100644 --- a/outscale/resource_outscale_virtual_gateway_route_propagation_test.go +++ b/outscale/resource_outscale_virtual_gateway_route_propagation_test.go @@ -13,7 +13,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIVirtualRoutePropagation_basic(t *testing.T) { +func TestAccNet_WithVirtualRoutePropagation_basic(t *testing.T) { t.Parallel() rBgpAsn := utils.RandIntRange(64512, 65534) diff --git a/outscale/resource_outscale_virtual_gateway_test.go b/outscale/resource_outscale_virtual_gateway_test.go index 2bb59bdfe..a8572cee7 100644 --- a/outscale/resource_outscale_virtual_gateway_test.go +++ b/outscale/resource_outscale_virtual_gateway_test.go @@ -15,7 +15,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIVirtualGateway_basic(t *testing.T) { +func TestAccNet_WithVirtualGateway_basic(t *testing.T) { t.Parallel() var v, v2 oscgo.VirtualGateway @@ -46,7 +46,7 @@ func TestAccOutscaleOAPIVirtualGateway_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIVirtualGatewayChangeTags(t *testing.T) { +func TestAccNet_WithVirtualGatewayChangeTags(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) @@ -64,7 +64,7 @@ func TestAccOutscaleOAPIVirtualGatewayChangeTags(t *testing.T) { }) } -func TestAccOutscaleOAPIVirtualGateway_delete(t *testing.T) { +func TestAccNet_withVirtualGateway_delete(t *testing.T) { var virtualGateway oscgo.VirtualGateway testDeleted := func(r string) resource.TestCheckFunc { @@ -98,7 +98,7 @@ func TestAccOutscaleOAPIVirtualGateway_delete(t *testing.T) { }) } -func TestAccOutscaleOAPIVirtualGateway_importBasic(t *testing.T) { +func TestAccNet_ImportVirtualGateway_Basic(t *testing.T) { resourceName := "outscale_virtual_gateway.foo" resource.ParallelTest(t, resource.TestCase{ diff --git a/outscale/resource_outscale_vm_test.go b/outscale/resource_outscale_vm_test.go index 7308bafd6..3d00d9866 100644 --- a/outscale/resource_outscale_vm_test.go +++ b/outscale/resource_outscale_vm_test.go @@ -16,15 +16,15 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIVM_Basic(t *testing.T) { +func TestAccVM_Basic(t *testing.T) { t.Parallel() var server oscgo.Vm resourceName := "outscale_vm.basic" omi := os.Getenv("OUTSCALE_IMAGEID") - region := fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION")) keypair := os.Getenv("OUTSCALE_KEYPAIR") + region := fmt.Sprintf("%sa", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -46,12 +46,12 @@ func TestAccOutscaleOAPIVM_Basic(t *testing.T) { }) } -func TestAccOutscaleOAPIVMBehavior_Basic(t *testing.T) { +func TestAccVM_Behavior_Basic(t *testing.T) { t.Parallel() var server oscgo.Vm omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") + region := fmt.Sprintf("%sa", utils.GetRegion()) resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -61,36 +61,36 @@ func TestAccOutscaleOAPIVMBehavior_Basic(t *testing.T) { { Config: testAccCheckOutscaleOAPIVMBehaviorConfigBasic(omi, "tinav4.c2r2p2", region, keypair, "high", "stop"), Check: resource.ComposeTestCheckFunc( - testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server), + testAccCheckOutscaleOAPIVMExists("outscale_vm.basicr1", &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), resource.TestCheckResourceAttr( - "outscale_vm.basic", "image_id", omi), + "outscale_vm.basicr1", "image_id", omi), resource.TestCheckResourceAttr( - "outscale_vm.basic", "vm_type", "tinav4.c2r2p2"), + "outscale_vm.basicr1", "vm_type", "tinav4.c2r2p2"), ), }, { Config: testAccCheckOutscaleOAPIVMBehaviorConfigBasic(omi, "tinav4.c2r2p2", region, keypair, "highest", "restart"), Check: resource.ComposeTestCheckFunc( - testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server), + testAccCheckOutscaleOAPIVMExists("outscale_vm.basicr1", &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), resource.TestCheckResourceAttr( - "outscale_vm.basic", "image_id", omi), + "outscale_vm.basicr1", "image_id", omi), resource.TestCheckResourceAttr( - "outscale_vm.basic", "vm_type", "tinav4.c2r2p2"), + "outscale_vm.basicr1", "vm_type", "tinav4.c2r2p2"), ), }, }, }) } -func TestAccOutscaleOAPIVM_importBasic(t *testing.T) { +func TestAccVM_importBasic(t *testing.T) { var ( server oscgo.Vm - resourceName = "outscale_vm.basic" + resourceName = "outscale_vm.basic_import" omi = os.Getenv("OUTSCALE_IMAGEID") - region = fmt.Sprintf("%sa", os.Getenv("OUTSCALE_REGION")) keypair = os.Getenv("OUTSCALE_KEYPAIR") + region = fmt.Sprintf("%sa", utils.GetRegion()) ) resource.ParallelTest(t, resource.TestCase{ @@ -130,10 +130,9 @@ func testAccCheckOutscaleVMImportStateIDFunc(resourceName string) resource.Impor } } -func TestAccOutscaleOAPIVM_withNicAttached(t *testing.T) { +func TestAccNet_VM_withNicAttached(t *testing.T) { var server oscgo.Vm omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") resourceName := "outscale_vm.basic" @@ -143,7 +142,7 @@ func TestAccOutscaleOAPIVM_withNicAttached(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVMConfigBasicWithNicAttached(omi, "tinav4.c2r2p2", region, keypair), + Config: testAccCheckOutscaleOAPIVMConfigBasicWithNicAttached(omi, "tinav4.c2r2p2", utils.GetRegion(), keypair), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVMExists(resourceName, &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), @@ -155,12 +154,11 @@ func TestAccOutscaleOAPIVM_withNicAttached(t *testing.T) { }) } -func TestAccOutscaleOAPIVM_withTags(t *testing.T) { +func TestAccVM_withTags(t *testing.T) { + t.Parallel() var server oscgo.Vm omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") - sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, @@ -168,7 +166,7 @@ func TestAccOutscaleOAPIVM_withTags(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", region, "Terraform-VM", keypair, sgId), + Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), "Terraform-VM", keypair), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), @@ -182,7 +180,7 @@ func TestAccOutscaleOAPIVM_withTags(t *testing.T) { }) } -func TestAccOutscaleOAPIVM_withNics(t *testing.T) { +func TestAccNet_VM_withNics(t *testing.T) { var server oscgo.Vm omi := os.Getenv("OUTSCALE_IMAGEID") keypair := os.Getenv("OUTSCALE_KEYPAIR") @@ -193,7 +191,7 @@ func TestAccOutscaleOAPIVM_withNics(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, "tinav4.c2r2p2", keypair), + Config: testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, "tinav4.c2r2p2", keypair, utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), @@ -207,11 +205,12 @@ func TestAccOutscaleOAPIVM_withNics(t *testing.T) { }) } -func TestAccOutscaleOAPIVM_Update(t *testing.T) { - region := os.Getenv("OUTSCALE_REGION") +func TestAccVM_UpdateKeypair(t *testing.T) { + t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") keypair := os.Getenv("OUTSCALE_KEYPAIR") sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") + region := utils.GetRegion() var before oscgo.Vm var after oscgo.Vm @@ -242,10 +241,9 @@ func TestAccOutscaleOAPIVM_Update(t *testing.T) { }) } -func TestAccOutscaleOAPIVM_WithSubnet(t *testing.T) { +func TestAccNet_VM_WithSubnet(t *testing.T) { var server oscgo.Vm omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") resource.Test(t, resource.TestCase{ @@ -254,7 +252,7 @@ func TestAccOutscaleOAPIVM_WithSubnet(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVMConfigWithSubnet(omi, "tinav4.c2r2p2", region, keypair), + Config: testAccCheckOutscaleOAPIVMConfigWithSubnet(omi, "tinav4.c2r2p2", utils.GetRegion(), keypair), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), @@ -268,34 +266,8 @@ func TestAccOutscaleOAPIVM_WithSubnet(t *testing.T) { }) } -func TestAccOutscaleOAPIVM_WithBlockDeviceMappings(t *testing.T) { - var server oscgo.Vm - omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") - keypair := os.Getenv("OUTSCALE_KEYPAIR") - vmType := "tinav4.c2r2p2" - - resource.Test(t, resource.TestCase{ - PreCheck: func() { testAccPreCheck(t) }, - Providers: testAccProviders, - CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, - Steps: []resource.TestStep{ - { - Config: testAccCheckOutscaleOAPIVMConfigWithBlockDeviceMappings(omi, vmType, region, keypair), - Check: resource.ComposeTestCheckFunc( - testAccCheckOutscaleOAPIVMExists("outscale_vm.basic", &server), - testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), - resource.TestCheckResourceAttr( - "outscale_vm.basic", "image_id", omi), - resource.TestCheckResourceAttr( - "outscale_vm.basic", "vm_type", vmType), - ), - }, - }, - }) -} - -func TestAccOutscaleOAPIVM_DeletionProtectionUpdate(t *testing.T) { +func TestAccVM_UpdateDeletionProtection(t *testing.T) { + t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") keypair := os.Getenv("OUTSCALE_KEYPAIR") @@ -320,11 +292,10 @@ func TestAccOutscaleOAPIVM_DeletionProtectionUpdate(t *testing.T) { }) } -func TestAccOutscaleOAPIVMTags_Update(t *testing.T) { +func TestAccVM_UpdateTags(t *testing.T) { + t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") - sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") //TODO: check tags resource.Test(t, resource.TestCase{ @@ -333,21 +304,20 @@ func TestAccOutscaleOAPIVMTags_Update(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", region, "Terraform-VM", keypair, sgId), + Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), "Terraform-VM", keypair), //Check: resource.ComposeTestCheckFunc(), }, { - Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", region, "Terraform-VM2", keypair, sgId), + Config: testAccVmsConfigUpdateOAPIVMTags(omi, "tinav4.c2r2p2", utils.GetRegion(), "Terraform-VM2", keypair), //Check: resource.ComposeTestCheckFunc(), }, }, }) } -func TestAccOutscaleOAPIVM_WithNet(t *testing.T) { +func TestAccNet_WithVM_PublicIp_Link(t *testing.T) { var server oscgo.Vm omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") vmType := "tinav4.c2r2p2" @@ -357,7 +327,7 @@ func TestAccOutscaleOAPIVM_WithNet(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleOAPIVMConfigWithNet(omi, vmType, region, keypair), + Config: testAccCheckOutscaleOAPIVMConfigWithNet(omi, vmType, utils.GetRegion(), keypair), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVMExists("outscale_vm.outscale_vmnet", &server), testAccCheckOutscaleOAPIVMAttributes(t, &server, omi), @@ -371,9 +341,9 @@ func TestAccOutscaleOAPIVM_WithNet(t *testing.T) { }) } -func TestAccOutscaleOAPIVM_multiBlockDeviceMapping(t *testing.T) { +func TestAccVM_multiBlockDeviceMapping(t *testing.T) { + t.Parallel() var server oscgo.Vm - region := os.Getenv("OUTSCALE_REGION") omi := os.Getenv("OUTSCALE_IMAGEID") keypair := os.Getenv("OUTSCALE_KEYPAIR") @@ -383,7 +353,7 @@ func TestAccOutscaleOAPIVM_multiBlockDeviceMapping(t *testing.T) { CheckDestroy: testAccCheckOutscaleOAPIVMDestroy, Steps: []resource.TestStep{ { - Config: testAccCheckOutscaleVMWithMultiBlockDeviceMapping(region, omi, keypair), + Config: testAccCheckOutscaleVMWithMultiBlockDeviceMapping(utils.GetRegion(), omi, keypair), Check: resource.ComposeTestCheckFunc( testAccCheckOutscaleOAPIVMExists("outscale_vm.outscale_vm", &server), resource.TestCheckResourceAttr("outscale_vm.outscale_vm", "image_id", omi), @@ -418,18 +388,27 @@ func testAccCheckOutscaleVMWithMultiBlockDeviceMapping(region, omi, keypair stri delete_on_vm_deletion = true } } - + block_device_mappings { device_name = "/dev/sdb" bsu { volume_size = 30 - volume_type = "io1" - iops = 150 + volume_type = "gp2" snapshot_id = outscale_snapshot.snapshot.id delete_on_vm_deletion = false } } + block_device_mappings { + device_name = "/dev/sdc" + bsu { + volume_size = 100 + volume_type = "gp2" + snapshot_id = outscale_snapshot.snapshot.id + delete_on_vm_deletion = true + } + } + tags { key = "name" value = "VM with multiple Block Device Mappings" @@ -668,11 +647,12 @@ func testAccCheckOutscaleOAPIVMConfigBasic(omi, vmType, region, keypair string) func testAccCheckOutscaleOAPIVMConfigImport(omi, vmType, region, keypair string) string { return fmt.Sprintf(` - resource "outscale_vm" "basic" { + resource "outscale_vm" "basic_import" { image_id = "%[1]s" vm_type = "%[2]s" - keypair_name = "%[4]s" + keypair_name = "%[4]s" placement_subregion_name = "%[3]s" + tags { key = "name" value = "Terraform-VM-import" @@ -730,7 +710,7 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNicAttached(omi, vmType, region, k }`, omi, vmType, region, keypair) } -func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string) string { +func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair, region string) string { return fmt.Sprintf(`resource "outscale_net" "outscale_net" { ip_range = "10.0.0.0/16" } @@ -738,7 +718,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 = "%[4]sa" } resource "outscale_nic" "outscale_nic" { @@ -752,13 +732,17 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string) } resource "outscale_vm" "basic" { - image_id = "%s" - vm_type = "%s" - keypair_name = "%s" + image_id = "%[1]s" + vm_type = "%[2]s" + keypair_name = "%[3]s" nics { device_number = 0 subnet_id = outscale_subnet.outscale_subnet.subnet_id + + # nic_id = outscale_nic.outscale_nic.nic_id + # secondary_private_ip_count = 1 + security_group_ids = [outscale_security_group.outscale_security_group.security_group_id] private_ips { @@ -771,20 +755,11 @@ func testAccCheckOutscaleOAPIVMConfigBasicWithNics(omi, vmType, keypair string) is_primary = false } } - }`, omi, vmType, keypair) + }`, omi, vmType, keypair, region) } func testAccVmsConfigUpdateOAPIVMKey(omi, vmType, region, keypair, sgId string) string { return fmt.Sprintf(` - resource "outscale_net" "net" { - ip_range = "10.0.0.0/16" - - tags { - key = "Name" - value = "testacc-security-group-rs" - } - } - resource "outscale_security_group" "sg" { security_group_name = "%[4]s" description = "Used in the terraform acceptance tests" @@ -793,8 +768,6 @@ func testAccVmsConfigUpdateOAPIVMKey(omi, vmType, region, keypair, sgId string) key = "Name" value = "tf-acc-test" } - - net_id = outscale_net.net.id } resource "outscale_vm" "basic" { @@ -807,34 +780,13 @@ func testAccVmsConfigUpdateOAPIVMKey(omi, vmType, region, keypair, sgId string) `, omi, vmType, region, keypair, sgId) } -func testAccVmsConfigUpdateOAPIVMTags(omi, vmType string, region, value, keypair, sgId string) string { +func testAccVmsConfigUpdateOAPIVMTags(omi, vmType, region, value, keypair string) string { return fmt.Sprintf(` - resource "outscale_net" "net" { - ip_range = "10.0.0.0/16" - - tags { - key = "Name" - value = "testacc-security-group-rs" - } - } - - resource "outscale_security_group" "sg" { - security_group_name = "%[5]s" - description = "Used in the terraform acceptance tests" - - tags { - key = "Name" - value = "tf-acc-test" - } - - net_id = outscale_net.net.id - } resource "outscale_vm" "basic" { image_id = "%[1]s" vm_type = "%[2]s" keypair_name = "%[5]s" - security_group_ids = ["%[6]s"] placement_subregion_name = "%[3]sb" tags { @@ -842,7 +794,7 @@ func testAccVmsConfigUpdateOAPIVMTags(omi, vmType string, region, value, keypair value = "%[4]s" } } - `, omi, vmType, region, value, keypair, sgId) + `, omi, vmType, region, value, keypair) } func testAccCheckOutscaleOAPIVMConfigWithSubnet(omi, vmType, region, keypair string) string { @@ -880,57 +832,6 @@ func testAccCheckOutscaleOAPIVMConfigWithSubnet(omi, vmType, region, keypair str `, omi, vmType, region, keypair) } -func testAccCheckOutscaleOAPIVMConfigWithBlockDeviceMappings(omi, vmType, region, keypair string) string { - return fmt.Sprintf(` - resource "outscale_volume" "external1" { - subregion_name = "%[3]sa" - size = 1 - } - - resource "outscale_snapshot" "snapshot" { - volume_id = outscale_volume.external1.id - } - - resource "outscale_vm" "basic" { - image_id = "%[1]s" - vm_type = "%[2]s" - keypair_name = "%[4]s" - - block_device_mappings { - device_name = "/dev/sdb" - no_device = "/dev/xvdb" - bsu { - volume_size = 15 - volume_type = "standard" - snapshot_id = outscale_snapshot.snapshot.id - delete_on_vm_deletion = true - } - } - - block_device_mappings { - device_name = "/dev/sdc" - bsu { - volume_size = 22 - volume_type = "io1" - iops = 150 - snapshot_id = outscale_snapshot.snapshot.id - delete_on_vm_deletion = true - } - } - - block_device_mappings { - device_name = "/dev/sdc" - bsu { - volume_size = 22 - volume_type = "io1" - iops = 150 - snapshot_id = outscale_snapshot.snapshot.id - } - } - } - `, omi, vmType, region, keypair) -} - func testAccCheckOutscaleOAPIVMConfigWithNet(omi, vmType, region, keypair string) string { return fmt.Sprintf(` resource "outscale_net" "outscale_net" { @@ -944,7 +845,7 @@ func testAccCheckOutscaleOAPIVMConfigWithNet(omi, vmType, region, keypair string resource "outscale_subnet" "outscale_subnet" { net_id = outscale_net.outscale_net.net_id ip_range = "10.0.0.0/24" - subregion_name = "%[3]sb" + subregion_name = "%[3]sa" tags { key = "name" @@ -963,8 +864,7 @@ func testAccCheckOutscaleOAPIVMConfigWithNet(omi, vmType, region, keypair string } resource "outscale_route_table" "outscale_route_table" { - net_id = "${outscale_net.outscale_net.net_id}" - + net_id = outscale_net.outscale_net.net_id tags { key = "name" value = "Terraform_RT" @@ -978,7 +878,7 @@ func testAccCheckOutscaleOAPIVMConfigWithNet(omi, vmType, region, keypair string resource "outscale_internet_service_link" "outscale_internet_service_link" { internet_service_id = outscale_internet_service.outscale_internet_service.internet_service_id - net_id = "${outscale_net.outscale_net.net_id}" + net_id = outscale_net.outscale_net.net_id } resource "outscale_route" "outscale_route" { @@ -1017,11 +917,11 @@ func assertEqual(t *testing.T, a interface{}, b interface{}, message string) { func testAccCheckOutscaleOAPIVMBehaviorConfigBasic(omi, vmType, region, keypair, perfomance, vmBehavior string) string { return fmt.Sprintf(` - resource "outscale_vm" "basic" { + resource "outscale_vm" "basicr1" { image_id = "%[1]s" vm_type = "%[2]s" keypair_name = "%[4]s" - placement_subregion_name = "%[3]sb" + placement_subregion_name = "%[3]s" vm_initiated_shutdown_behavior = "%[6]s" performance = "%[5]s" diff --git a/outscale/resource_outscale_volume_test.go b/outscale/resource_outscale_volume_test.go index 3064e0f1d..6a9f5e1a4 100644 --- a/outscale/resource_outscale_volume_test.go +++ b/outscale/resource_outscale_volume_test.go @@ -14,9 +14,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIVolume_basic(t *testing.T) { +func TestAccOthers_Volume_basic(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") var v oscgo.Volume resource.Test(t, resource.TestCase{ @@ -25,7 +24,7 @@ func TestAccOutscaleOAPIVolume_basic(t *testing.T) { Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testAccOutscaleOAPIVolumeConfig(region), + Config: testAccOutscaleOAPIVolumeConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( testAccCheckOAPIVolumeExists("outscale_volume.test", &v), ), @@ -39,9 +38,9 @@ func TestAccOutscaleOAPIVolume_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIVolume_updateSize(t *testing.T) { +func TestAccOthers_Volume_updateSize(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") + region := utils.GetRegion() var v oscgo.Volume resource.Test(t, resource.TestCase{ @@ -70,23 +69,46 @@ func TestAccOutscaleOAPIVolume_updateSize(t *testing.T) { }) } -func TestAccOutscaleOAPIVolume_io1Type(t *testing.T) { +func TestAccOthers_Volume_io1Type(t *testing.T) { t.Parallel() - region := os.Getenv("OUTSCALE_REGION") + if os.Getenv("IS_IO1_TEST_QUOTA") == "true" { + var v oscgo.Volume + resource.Test(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + + }, + IDRefreshName: "outscale_volume.test-io1", + Providers: testAccProviders, + Steps: []resource.TestStep{ + { + Config: test_IO1VolumeTypeConfig(utils.GetRegion()), + Check: resource.ComposeTestCheckFunc( + testAccCheckOAPIVolumeExists("outscale_volume.test-io1", &v), + ), + }, + }, + }) + } else { + t.Skip("will be done soon") + } +} +func TestAccOthers_GP2_Volume_Type(t *testing.T) { + t.Parallel() var v oscgo.Volume resource.Test(t, resource.TestCase{ PreCheck: func() { testAccPreCheck(t) }, - IDRefreshName: "outscale_volume.test-io", + IDRefreshName: "outscale_volume.test-gp2", Providers: testAccProviders, Steps: []resource.TestStep{ { - Config: testOutscaleOAPIVolumeConfigIO1Type(region), + Config: test_GP2VolumeTypeConfig(utils.GetRegion()), Check: resource.ComposeTestCheckFunc( - testAccCheckOAPIVolumeExists("outscale_volume.test-io", &v), + testAccCheckOAPIVolumeExists("outscale_volume.test-gp2", &v), ), }, }, @@ -161,13 +183,23 @@ func testOutscaleOAPIVolumeConfigUpdateSize(region string) string { `, region) } -func testOutscaleOAPIVolumeConfigIO1Type(region string) string { +func test_IO1VolumeTypeConfig(region string) string { return fmt.Sprintf(` - resource "outscale_volume" "test-io" { + resource "outscale_volume" "test-io1" { subregion_name = "%sa" - volume_type = "io1" + volume_type = "gp2" size = 10 iops = 100 } `, region) } + +func test_GP2VolumeTypeConfig(region string) string { + return fmt.Sprintf(` + resource "outscale_volume" "test-gp2" { + subregion_name = "%sa" + volume_type = "gp2" + size = 10 + } + `, region) +} diff --git a/outscale/resource_outscale_volumes_link_test.go b/outscale/resource_outscale_volumes_link_test.go index 05903c2ab..264f5571e 100644 --- a/outscale/resource_outscale_volumes_link_test.go +++ b/outscale/resource_outscale_volumes_link_test.go @@ -6,17 +6,16 @@ import ( "testing" oscgo "github.com/outscale/osc-sdk-go/v2" + "github.com/terraform-providers/terraform-provider-outscale/utils" "github.com/hashicorp/terraform-plugin-sdk/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleOAPIVolumeAttachment_basic(t *testing.T) { +func TestAccVM_WithVolumeAttachment_basic(t *testing.T) { t.Parallel() omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") - sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") var i oscgo.Vm var v oscgo.Volume @@ -30,7 +29,7 @@ func TestAccOutscaleOAPIVolumeAttachment_basic(t *testing.T) { CheckDestroy: testAccCheckOAPIVolumeAttachmentDestroy, Steps: []resource.TestStep{ { - Config: testAccOAPIVolumeAttachmentConfig(omi, "tinav4.c2r2p2", region, keypair, sgId), + Config: testAccOAPIVolumeAttachmentConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), keypair), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( "outscale_volumes_link.ebs_att", "device_name", "/dev/sdh"), @@ -43,11 +42,9 @@ func TestAccOutscaleOAPIVolumeAttachment_basic(t *testing.T) { }) } -func TestAccOutscaleOAPIVolumeAttachment_importBasic(t *testing.T) { +func TestAccVM_ImportVolumeAttachment_Basic(t *testing.T) { omi := os.Getenv("OUTSCALE_IMAGEID") - region := os.Getenv("OUTSCALE_REGION") keypair := os.Getenv("OUTSCALE_KEYPAIR") - sgId := os.Getenv("OUTSCALE_SECURITYGROUPID") resourceName := "outscale_volumes_link.ebs_att" @@ -57,7 +54,7 @@ func TestAccOutscaleOAPIVolumeAttachment_importBasic(t *testing.T) { CheckDestroy: testAccCheckOAPIVolumeAttachmentDestroy, Steps: []resource.TestStep{ { - Config: testAccOAPIVolumeAttachmentConfig(omi, "tinav4.c2r2p2", region, keypair, sgId), + Config: testAccOAPIVolumeAttachmentConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), keypair), }, { ResourceName: resourceName, @@ -113,34 +110,12 @@ func testAccCheckOAPIVolumeAttachmentExists(n string, i *oscgo.Vm, v *oscgo.Volu } } -func testAccOAPIVolumeAttachmentConfig(omi, vmType, region, keypair, sgId string) string { +func testAccOAPIVolumeAttachmentConfig(omi, vmType, region, keypair string) string { return fmt.Sprintf(` - resource "outscale_net" "net" { - ip_range = "10.0.0.0/16" - - tags { - key = "Name" - value = "testacc-security-group-rs" - } - } - - resource "outscale_security_group" "sg" { - security_group_name = "%[4]s" - description = "Used in the terraform acceptance tests" - - tags { - key = "Name" - value = "tf-acc-test" - } - - net_id = "${outscale_net.net.id}" - } - resource "outscale_vm" "web" { image_id = "%[1]s" vm_type = "%[2]s" keypair_name = "%[4]s" - security_group_ids = ["%[5]s"] placement_subregion_name = "%[3]sb" } @@ -152,8 +127,8 @@ func testAccOAPIVolumeAttachmentConfig(omi, vmType, region, keypair, sgId string resource "outscale_volumes_link" "ebs_att" { device_name = "/dev/sdh" - volume_id = "${outscale_volume.volume.id}" - vm_id = "${outscale_vm.web.id}" + volume_id = outscale_volume.volume.id + vm_id = outscale_vm.web.id } - `, omi, vmType, region, keypair, sgId) + `, omi, vmType, region, keypair) } diff --git a/outscale/resource_outscale_vpn_connection_route_test.go b/outscale/resource_outscale_vpn_connection_route_test.go index 397ee0d49..0ee2f9477 100644 --- a/outscale/resource_outscale_vpn_connection_route_test.go +++ b/outscale/resource_outscale_vpn_connection_route_test.go @@ -14,7 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/terraform" ) -func TestAccOutscaleVPNConnectionRoute_basic(t *testing.T) { +func TestAccOthers_VPNConnectionRoute_basic(t *testing.T) { t.Parallel() resourceName := "outscale_vpn_connection_route.foo" @@ -38,7 +38,7 @@ func TestAccOutscaleVPNConnectionRoute_basic(t *testing.T) { }) } -func TestAccOutscaleVPNConnectionRouteimport_basic(t *testing.T) { +func TestAccOthers_ImportVPNConnectionRoute_basic(t *testing.T) { t.Parallel() if os.Getenv("TEST_QUOTA") == "true" { resourceName := "outscale_vpn_connection_route.foo" @@ -177,15 +177,15 @@ func testAccOutscaleVPNConnectionRouteConfig(publicIP, destinationIPRange string } resource "outscale_vpn_connection" "vpn_connection" { - client_gateway_id = "${outscale_client_gateway.customer_gateway.id}" - virtual_gateway_id = "${outscale_virtual_gateway.virtual_gateway.id}" + client_gateway_id = outscale_client_gateway.customer_gateway.id + virtual_gateway_id = outscale_virtual_gateway.virtual_gateway.id connection_type = "ipsec.1" static_routes_only = true } resource "outscale_vpn_connection_route" "foo" { destination_ip_range = "%s" - vpn_connection_id = "${outscale_vpn_connection.vpn_connection.id}" + vpn_connection_id = outscale_vpn_connection.vpn_connection.id } `, publicIP, destinationIPRange) } diff --git a/utils/utils.go b/utils/utils.go index e2524f58d..b603311a3 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -6,6 +6,7 @@ import ( "log" "math/rand" "net/http" + "os" "strconv" "time" @@ -233,3 +234,11 @@ func StringSlicePtrToInterfaceSlice(list *[]string) []interface{} { func I32toa(i int32) string { return strconv.FormatInt(int64(i), 10) } + +func GetRegion() string { + region := fmt.Sprintf("%s", os.Getenv("OUTSCALE_REGION")) + if region == "" { + region = fmt.Sprintf("%s", os.Getenv("OSC_REGION")) + } + return region +}