@@ -292,6 +292,60 @@ func TestAccAliCloudVPCHavipAttachment_basic_multiple_instance_bug_fix(t *testin
292
292
})
293
293
}
294
294
295
+ func TestAccAliCloudVPCHavipAttachment_basic_multiple_havip_bug_fix (t * testing.T ) {
296
+ var v map [string ]interface {}
297
+ resourceId := "alicloud_havip_attachment.default"
298
+ ra := resourceAttrInit (resourceId , AliCloudHavipAttachmentMap0 )
299
+ rc := resourceCheckInitWithDescribeMethod (resourceId , & v , func () interface {} {
300
+ return & VpcServiceV2 {testAccProvider .Meta ().(* connectivity.AliyunClient )}
301
+ }, "DescribeVpcHaVipAttachment" )
302
+ rac := resourceAttrCheckInit (rc , ra )
303
+ testAccCheck := rac .resourceAttrMapUpdateSet ()
304
+ rand := acctest .RandIntRange (10000 , 99999 )
305
+ name := fmt .Sprintf ("tf-testacc%shavipattachment%d" , defaultRegionToTest , rand )
306
+ testAccConfig := resourceTestAccConfigFunc (resourceId , name , AliCloudHavipAttachmentBasicDependence_bug_fix )
307
+ resource .Test (t , resource.TestCase {
308
+ PreCheck : func () {
309
+ testAccPreCheck (t )
310
+ },
311
+
312
+ IDRefreshName : resourceId ,
313
+ Providers : testAccProviders ,
314
+ CheckDestroy : rac .checkResourceDestroy (),
315
+ Steps : []resource.TestStep {
316
+ {
317
+ Config : testAccConfig (map [string ]interface {}{
318
+ "ha_vip_id" : "${alicloud_havip.default.id}" ,
319
+ "instance_id" : "${alicloud_ecs_network_interface_attachment.default.0.network_interface_id}" ,
320
+ "instance_type" : "NetworkInterface" ,
321
+ "force" : "false" ,
322
+ }),
323
+ Check : resource .ComposeTestCheckFunc (
324
+ testAccCheck (map [string ]string {
325
+ "ha_vip_id" : CHECKSET ,
326
+ "instance_id" : CHECKSET ,
327
+ "instance_type" : "NetworkInterface" ,
328
+ }),
329
+ ),
330
+ },
331
+ {
332
+ Config : testAccConfig (map [string ]interface {}{
333
+ "force" : "true" ,
334
+ }),
335
+ Check : resource .ComposeTestCheckFunc (
336
+ testAccCheck (map [string ]string {}),
337
+ ),
338
+ },
339
+ {
340
+ ResourceName : resourceId ,
341
+ ImportState : true ,
342
+ ImportStateVerify : true ,
343
+ ImportStateVerifyIgnore : []string {"force" },
344
+ },
345
+ },
346
+ })
347
+ }
348
+
295
349
var AliCloudHavipAttachmentMap0 = map [string ]string {}
296
350
297
351
func AliCloudHavipAttachmentBasicDependence0 (name string ) string {
@@ -314,6 +368,9 @@ func AliCloudHavipAttachmentBasicDependence0(name string) string {
314
368
data "alicloud_instance_types" "default" {
315
369
availability_zone = data.alicloud_zones.default.zones.0.id
316
370
image_id = data.alicloud_images.default.images.0.id
371
+ cpu_core_count = 2
372
+ memory_size = 8
373
+ instance_type_family = "ecs.g6"
317
374
}
318
375
319
376
resource "alicloud_vpc" "default" {
@@ -373,6 +430,9 @@ func AliCloudHavipAttachmentBasicDependence1(name string) string {
373
430
data "alicloud_instance_types" "default" {
374
431
availability_zone = data.alicloud_zones.default.zones.0.id
375
432
image_id = data.alicloud_images.default.images.0.id
433
+ cpu_core_count = 2
434
+ memory_size = 8
435
+ instance_type_family = "ecs.g6"
376
436
}
377
437
378
438
resource "alicloud_vpc" "default" {
@@ -432,6 +492,9 @@ func AliCloudHavipAttachmentBasicDependence2(name string) string {
432
492
data "alicloud_instance_types" "default" {
433
493
availability_zone = data.alicloud_zones.default.zones.0.id
434
494
image_id = data.alicloud_images.default.images.0.id
495
+ cpu_core_count = 2
496
+ memory_size = 8
497
+ instance_type_family = "ecs.g6"
435
498
}
436
499
437
500
resource "alicloud_vpc" "default" {
@@ -502,6 +565,9 @@ func AliCloudHavipAttachmentBasicDependence_bug_fix(name string) string {
502
565
data "alicloud_instance_types" "default" {
503
566
availability_zone = data.alicloud_zones.default.zones.0.id
504
567
image_id = data.alicloud_images.default.images.0.id
568
+ cpu_core_count = 2
569
+ memory_size = 8
570
+ instance_type_family = "ecs.g6"
505
571
}
506
572
507
573
resource "alicloud_vpc" "default" {
@@ -521,6 +587,32 @@ func AliCloudHavipAttachmentBasicDependence_bug_fix(name string) string {
521
587
vpc_id = alicloud_vpc.default.id
522
588
}
523
589
590
+ resource "alicloud_havip" "example" {
591
+ count = 21
592
+ vswitch_id = alicloud_vswitch.default.id
593
+ description = var.name
594
+ }
595
+
596
+ resource "alicloud_instance" "example" {
597
+ count = 21
598
+ availability_zone = data.alicloud_zones.default.zones.0.id
599
+ vswitch_id = alicloud_vswitch.default.id
600
+ image_id = data.alicloud_images.default.images.0.id
601
+ instance_type = data.alicloud_instance_types.default.instance_types.0.id
602
+ system_disk_category = "cloud_efficiency"
603
+ internet_charge_type = "PayByTraffic"
604
+ internet_max_bandwidth_out = 5
605
+ security_groups = [alicloud_security_group.default.id]
606
+ instance_name = var.name
607
+ user_data = "echo 'net.ipv4.ip_forward=1'>> /etc/sysctl.conf"
608
+ }
609
+
610
+ resource "alicloud_havip_attachment" "example" {
611
+ count = 21
612
+ havip_id = alicloud_havip.example[count.index].id
613
+ instance_id = alicloud_instance.example[count.index].id
614
+ }
615
+
524
616
resource "alicloud_havip" "default" {
525
617
vswitch_id = alicloud_vswitch.default.id
526
618
description = var.name
0 commit comments