Skip to content

Commit

Permalink
Enable attaching vms to LBU with 'backendIps' and update LoadBalancer…
Browse files Browse the repository at this point in the history
…Attachement
  • Loading branch information
FredericBerot-Armand authored and outscale-toa committed Jan 8, 2025
1 parent ccd38d7 commit f23028f
Show file tree
Hide file tree
Showing 28 changed files with 161 additions and 147 deletions.
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_image_export_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestAccVM_withImageExportTaskDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOutscaleImageExportTaskDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Config: testAccOutscaleImageExportTaskDataSourceConfig(omi, utils.TestAccVmType, utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleImageExportTaskDataSourceID("data.outscale_image_export_task.test"),
),
Expand Down
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_image_export_tasks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func TestAccVM_withImageExportTasksDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOutscaleImageExportTasksDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Config: testAccOutscaleImageExportTasksDataSourceConfig(omi, utils.TestAccVmType, utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleImageExportTaskDataSourceID("outscale_image_export_task.outscale_image_export_task"),
),
Expand Down
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAccVM_WithImageDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckOutscaleImageDataSourceBasicConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Config: testAccCheckOutscaleImageDataSourceBasicConfig(omi, utils.TestAccVmType, utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleImageDataSourceID("data.outscale_image.omi"),
),
Expand Down
2 changes: 1 addition & 1 deletion outscale/data_source_outscale_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestAccVM_WithImagesDataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckOutscaleImagesDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion(), imageName),
Config: testAccCheckOutscaleImagesDataSourceConfig(omi, utils.TestAccVmType, utils.GetRegion(), imageName),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleImagesDataSourceID("data.outscale_images.nat_ami"),
),
Expand Down
8 changes: 4 additions & 4 deletions outscale/data_source_outscale_public_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestAccVM_WithPublicIP(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceOutscalePublicIPConfigwithVM(omi, utils.GetRegion()),
Config: testAccDataSourceOutscalePublicIPConfigwithVM(omi, utils.GetRegion(), utils.TestAccVmType),
},
},
})
Expand Down Expand Up @@ -126,7 +126,7 @@ const testAccDataSourceOutscalePublicIPConfigWithTags = `
}
`

func testAccDataSourceOutscalePublicIPConfigwithVM(omi, region string) string {
func testAccDataSourceOutscalePublicIPConfigwithVM(omi, region, vmType string) string {
return fmt.Sprintf(`
resource "outscale_security_group" "sg_Pbip" {
security_group_name = "sg_data_ip"
Expand All @@ -140,7 +140,7 @@ func testAccDataSourceOutscalePublicIPConfigwithVM(omi, region string) string {
resource "outscale_vm" "outscale_vm" {
image_id = "%s"
vm_type = "tinav4.c2r2p2"
vm_type = "%[3]s"
keypair_name = "terraform-basic"
security_group_ids = [outscale_security_group.sg_Pbip.security_group_id]
}
Expand Down Expand Up @@ -171,5 +171,5 @@ func testAccDataSourceOutscalePublicIPConfigwithVM(omi, region string) string {
values = [outscale_public_ip_link.outscale_public_ip_link.link_public_ip_id]
}
}
`, omi, region)
`, omi, region, vmType)
}
3 changes: 2 additions & 1 deletion outscale/data_source_outscale_tag_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/outscale/terraform-provider-outscale/utils"
)

func TestAccVM_WithTagDataSource(t *testing.T) {
Expand All @@ -16,7 +17,7 @@ func TestAccVM_WithTagDataSource(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOAPITagDataSourceConfig(omi, "tinav4.c2r2p2"),
Config: testAccOAPITagDataSourceConfig(omi, utils.TestAccVmType),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.outscale_tag.web", "key", "Name"),
Expand Down
3 changes: 2 additions & 1 deletion outscale/data_source_outscale_vm_state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"github.com/outscale/terraform-provider-outscale/utils"
)

func TestAccVM_StateDataSource(t *testing.T) {
Expand All @@ -18,7 +19,7 @@ func TestAccVM_StateDataSource(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceOutscaleVmStateConfig(omi, "tinav4.c2r2p2"),
Config: testAccDataSourceOutscaleVmStateConfig(omi, utils.TestAccVmType),
Check: resource.ComposeTestCheckFunc(
testAccDataSourceOutscaleVMStateCheck("data.outscale_vm_state.state"),
),
Expand Down
3 changes: 2 additions & 1 deletion outscale/data_source_outscale_vm_states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/outscale/terraform-provider-outscale/utils"
)

func TestAccVM_StatesDataSource(t *testing.T) {
Expand All @@ -16,7 +17,7 @@ func TestAccVM_StatesDataSource(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccDataSourceOutscaleVMStatesConfig(omi, "tinav4.c2r2p2"),
Config: testAccDataSourceOutscaleVMStatesConfig(omi, utils.TestAccVmType),
},
},
})
Expand Down
4 changes: 2 additions & 2 deletions outscale/data_source_outscale_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func TestAccVM_DataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOAPIVMDataSourceConfig(omi, "tinav4.c2r2p2", utils.GetRegion()),
Config: testAccOAPIVMDataSourceConfig(omi, utils.TestAccVmType, utils.GetRegion()),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(datasourcceName, "image_id", omi),
resource.TestCheckResourceAttr(datasourcceName, "vm_type", "tinav4.c2r2p2"),
resource.TestCheckResourceAttr(datasourcceName, "vm_type", utils.TestAccVmType),
resource.TestCheckResourceAttr(datasourcceName, "tags.#", "1"),
),
},
Expand Down
5 changes: 3 additions & 2 deletions outscale/data_source_outscale_vms_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/outscale/terraform-provider-outscale/utils"
)

func TestAccVMS_DataSource_basic(t *testing.T) {
Expand All @@ -17,12 +18,12 @@ func TestAccVMS_DataSource_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOAPIVMSDataSourceConfig(omi, "tinav4.c2r2p2"),
Config: testAccOAPIVMSDataSourceConfig(omi, utils.TestAccVmType),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
"data.outscale_vms.basic_web", "vms.0.image_id", omi),
resource.TestCheckResourceAttr(
"data.outscale_vms.basic_web", "vms.0.vm_type", "tinav4.c2r2p2"),
"data.outscale_vms.basic_web", "vms.0.vm_type", utils.TestAccVmType),
),
},
},
Expand Down
8 changes: 4 additions & 4 deletions outscale/data_source_outscale_volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestAccVM_withVolumesDataSource(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccCheckOutscaleVolumesDataSourceConfigWithVM(utils.GetRegion(), omi, keypair),
Config: testAccCheckOutscaleVolumesDataSourceConfigWithVM(utils.GetRegion(), omi, keypair, utils.TestAccVmType),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscaleVolumeDataSourceID("data.outscale_volumes.outscale_volumes"),
resource.TestCheckResourceAttrSet("data.outscale_volumes.outscale_volumes", "volumes.#"),
Expand Down Expand Up @@ -113,7 +113,7 @@ func testAccCheckOutscaleVolumesDataSourceConfigWithMultipleVolumeIDsFilter(regi
`, region)
}

func testAccCheckOutscaleVolumesDataSourceConfigWithVM(region, imageID, keypair string) string {
func testAccCheckOutscaleVolumesDataSourceConfigWithVM(region, imageID, keypair, vmType string) string {
return fmt.Sprintf(`
resource "outscale_volume" "outscale_volume" {
subregion_name = "%[1]sa"
Expand Down Expand Up @@ -159,7 +159,7 @@ func testAccCheckOutscaleVolumesDataSourceConfigWithVM(region, imageID, keypair
image_id = "%[2]s"
keypair_name = "%[3]s"
security_group_ids = [outscale_security_group.sg_volumes.security_group_id]
vm_type = "tinav4.c2r2p2"
vm_type = "%[4]s"
}
resource "outscale_volume_link" "outscale_volume_link" {
Expand All @@ -186,5 +186,5 @@ func testAccCheckOutscaleVolumesDataSourceConfigWithVM(region, imageID, keypair
values = [outscale_vm.outscale_vm.vm_id]
}
}
`, region, imageID, keypair)
`, region, imageID, keypair, vmType)
}
2 changes: 0 additions & 2 deletions outscale/data_source_outscale_vpn_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func TestAccOthers_VPNConnectionDataSource_basic(t *testing.T) {
t.Parallel()
publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255))

resource.Test(t, resource.TestCase{
Expand All @@ -24,7 +23,6 @@ func TestAccOthers_VPNConnectionDataSource_basic(t *testing.T) {
}

func TestAccOthers_VPNConnectionDataSource_withFilters(t *testing.T) {
t.Parallel()
publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255))

resource.Test(t, resource.TestCase{
Expand Down
2 changes: 0 additions & 2 deletions outscale/data_source_outscale_vpn_connections_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
)

func TestAccOthers_VPNConnectionsDataSource_basic(t *testing.T) {
t.Parallel()
publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255))

resource.Test(t, resource.TestCase{
Expand All @@ -24,7 +23,6 @@ func TestAccOthers_VPNConnectionsDataSource_basic(t *testing.T) {
}

func TestAccOthers_VPNConnectionsDataSource_withFilters(t *testing.T) {
t.Parallel()
publicIP := fmt.Sprintf("172.0.0.%d", utils.RandIntRange(1, 255))

resource.Test(t, resource.TestCase{
Expand Down
4 changes: 2 additions & 2 deletions outscale/resource_outscale_image_export_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ func TestAccVM_withImageExportTask_basic(t *testing.T) {
Providers: testAccProviders,
Steps: []resource.TestStep{
{
Config: testAccOAPIImageExportTaskConfigBasic(omi, "tinav4.c2r2p2", region, imageName, ""),
Config: testAccOAPIImageExportTaskConfigBasic(omi, utils.TestAccVmType, region, imageName, ""),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscalemageExportTaskExists("outscale_image_export_task.outscale_image_export_task"),
),
},
{
Config: testAccOAPIImageExportTaskConfigBasic(omi, "tinav4.c2r2p2", region, imageName, tags),
Config: testAccOAPIImageExportTaskConfigBasic(omi, utils.TestAccVmType, region, imageName, tags),
Check: resource.ComposeTestCheckFunc(
testAccCheckOutscalemageExportTaskExists("outscale_image_export_task.outscale_image_export_task"),
),
Expand Down
12 changes: 6 additions & 6 deletions outscale/resource_outscale_image_launch_permission_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,29 +31,29 @@ func TestAccVM_WithImageLaunchPermission_Basic(t *testing.T) {
Steps: []r.TestStep{
// Scaffold everything
{
Config: testAccOutscaleImageLaunchPermissionConfig(omi, "tinav4.c2r2p2", region, accountID, keypair, true, rInt),
Config: testAccOutscaleImageLaunchPermissionConfig(omi, utils.TestAccVmType, region, accountID, keypair, true, rInt),
Check: r.ComposeTestCheckFunc(
testCheckResourceOAPILPIGetAttr("outscale_image.outscale_image", "id", &imageID),
),
},
// Drop just launch permission to test destruction
{
Config: testAccOutscaleImageLaunchPermissionConfig(omi, "tinav4.c2r2p2", region, accountID, keypair, false, rInt),
Config: testAccOutscaleImageLaunchPermissionConfig(omi, utils.TestAccVmType, region, accountID, keypair, false, rInt),
Check: r.ComposeTestCheckFunc(
testAccOutscaleImageLaunchPermissionDestroyed(accountID, &imageID),
),
},
// Re-add everything so we can test when AMI disappears
{
Config: testAccOutscaleImageLaunchPermissionConfig(omi, "tinav4.c2r2p2", region, accountID, keypair, true, rInt),
Config: testAccOutscaleImageLaunchPermissionConfig(omi, utils.TestAccVmType, region, accountID, keypair, true, rInt),
Check: r.ComposeTestCheckFunc(
testCheckResourceOAPILPIGetAttr("outscale_image.outscale_image", "id", &imageID),
),
},
// Here we delete the AMI to verify the follow-on refresh after this step
// should not error.
{
Config: testAccOutscaleImageLaunchPermissionConfig(omi, "tinav4.c2r2p2", region, accountID, keypair, true, rInt),
Config: testAccOutscaleImageLaunchPermissionConfig(omi, utils.TestAccVmType, region, accountID, keypair, true, rInt),
Check: r.ComposeTestCheckFunc(
testAccOutscaleImageDisappears(&imageID),
),
Expand All @@ -78,14 +78,14 @@ func TestAccVM_ImageLaunchPermissionDestruction_Basic(t *testing.T) {
Steps: []r.TestStep{
// Scaffold everything
{
Config: testAccOutscaleImageLaunchPermissionCreateConfig(omi, "tinav4.c2r2p2", region, keypair, rInt, true, false),
Config: testAccOutscaleImageLaunchPermissionCreateConfig(omi, utils.TestAccVmType, region, keypair, rInt, true, false),
Check: r.ComposeTestCheckFunc(
testCheckResourceOAPILPIGetAttr("outscale_image.outscale_image", "id", &imageID),
testAccOutscaleImageLaunchPermissionExists(accountID, &imageID),
),
},
{
Config: testAccOutscaleImageLaunchPermissionCreateConfig(omi, "tinav4.c2r2p2", region, keypair, rInt, true, true),
Config: testAccOutscaleImageLaunchPermissionCreateConfig(omi, utils.TestAccVmType, region, keypair, rInt, true, true),
Check: r.ComposeTestCheckFunc(
testCheckResourceOAPILPIGetAttr("outscale_image.outscale_image", "id", &imageID),
),
Expand Down
2 changes: 1 addition & 1 deletion outscale/resource_outscale_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestAccOthers_Image_basic(t *testing.T) {
CheckDestroy: testAccCheckOAPIImageDestroy,
Steps: []resource.TestStep{
{
Config: testAccOAPIImageConfigBasic(omi, "tinav4.c2r2p2", region, rInt),
Config: testAccOAPIImageConfigBasic(omi, utils.TestAccVmType, region, rInt),
Check: resource.ComposeTestCheckFunc(
testAccCheckOAPIImageExists("outscale_image.foo", &ami),
resource.TestCheckResourceAttr(
Expand Down
Loading

0 comments on commit f23028f

Please sign in to comment.