Skip to content

Commit c79a60c

Browse files
committed
add
1 parent 217e3ee commit c79a60c

File tree

10 files changed

+122
-58
lines changed

10 files changed

+122
-58
lines changed

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ require (
3030
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/api v1.0.285
3131
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway v1.0.763
3232
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825
33-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1052
33+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1071
3434
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824
3535
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.1051
3636
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cat v1.0.825
@@ -46,7 +46,7 @@ require (
4646
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/clb v1.0.1034
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033
4848
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1046
49-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1068
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1071
5050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1053
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.1058

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825 h1:yiC2lsZ
828828
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825/go.mod h1:6qtSa8OZKwJOWoOCYWVZd6+T62O96AxbPll0I43d4yw=
829829
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1052 h1:d7eK/iFBAL1P75UWcc+wupp2/W1KQHdTxB/YpJTaoUA=
830830
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1052/go.mod h1:o/8YQckpRRJ12COW2g9J9Fx+v5noOAsHkKVQpTctM+g=
831+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1071 h1:XtAPtAaj4rxUnxhLHhwk104R7ThGQI1E7Hnub4YXCB8=
832+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1071/go.mod h1:KiAIwNj6ovl/d1WOM7WFNdW6s9TsbYCq9xksjOQsQ7k=
831833
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824 h1:DVKvZ6h+qd7tadUrCjVAkCCmE3TsbK2ZmwGd3AJcpWc=
832834
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824/go.mod h1:DvBpDX/qdJG4KKLeULmRvhAjPYiw8za0HeTSu2y/lFw=
833835
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.0.1051 h1:ZwWmhAxXd88JDPs/8s2qW9SJblXNhIXWKWfeW7jtjlc=
@@ -943,6 +945,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1066 h1:D55
943945
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1066/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
944946
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1068 h1:mI0xoreGp9GkDJWkdzqgZcPsfoWXciahPAvEcaGSA6g=
945947
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1068/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
948+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1071 h1:Q/Ue/yRv4HSpaiFAnXIshoDjxzwyhwezEidXU49Boa4=
949+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1071/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
946950
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ=
947951
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY=
948952
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=

tencentcloud/services/as/extension_as.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ const (
181181
SCALING_MODE_WAKE_UP_STOPPED = "WAKE_UP_STOPPED_SCALING"
182182
)
183183

184+
const (
185+
REPLACE_MODE_RECREATE = "RECREATE"
186+
REPLACE_MODE_RESET = "RESET"
187+
)
188+
184189
const (
185190
REFRESH_ACTIVITIES_SUCCESSFUL = "SUCCESSFUL"
186191
)

tencentcloud/services/as/resource_tc_as_scaling_group.go

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,32 @@ func ResourceTencentCloudAsScalingGroup() *schema.Resource {
158158
ValidateFunc: tccommon.ValidateAllowedStringValue([]string{SCALING_GROUP_RETRY_POLICY_IMMEDIATE_RETRY,
159159
SCALING_GROUP_RETRY_POLICY_INCREMENTAL_INTERVALS}),
160160
},
161-
"scaling_mode": {
162-
Type: schema.TypeString,
163-
Optional: true,
164-
Description: "Indicates scaling mode which creates and terminates instances (classic method), or method first tries to start stopped instances (wake up stopped) to perform scaling operations. Available values: `CLASSIC_SCALING`, `WAKE_UP_STOPPED_SCALING`. Default: `CLASSIC_SCALING`.",
165-
},
166161
// Service Settings
167162
"replace_monitor_unhealthy": {
168163
Type: schema.TypeBool,
169164
Optional: true,
170165
Description: "Enables unhealthy instance replacement. If set to `true`, AS will replace instances that are flagged as unhealthy by Cloud Monitor.",
171166
},
167+
"scaling_mode": {
168+
Type: schema.TypeString,
169+
Optional: true,
170+
Description: "Indicates scaling mode which creates and terminates instances (classic method), or method first tries to start stopped instances (wake up stopped) to perform scaling operations. Available values: `CLASSIC_SCALING`, `WAKE_UP_STOPPED_SCALING`. Default: `CLASSIC_SCALING`.",
171+
},
172172
"replace_load_balancer_unhealthy": {
173173
Type: schema.TypeBool,
174174
Optional: true,
175175
Description: "Enable unhealthy instance replacement. If set to `true`, AS will replace instances that are found unhealthy in the CLB health check.",
176176
},
177+
"replace_mode": {
178+
Type: schema.TypeString,
179+
Optional: true,
180+
Description: "Replace mode of unhealthy replacement service. Valid values: RECREATE: Rebuild an instance to replace the original unhealthy instance. RESET: Performing a system reinstallation on unhealthy instances to keep information such as data disks, private IP addresses, and instance IDs unchanged. The instance login settings, HostName, enhanced services, and UserData will remain consistent with the current launch configuration. Default value: RECREATE. Note: This field may return null, indicating that no valid values can be obtained.",
181+
},
182+
"desired_capacity_sync_with_max_min_size": {
183+
Type: schema.TypeBool,
184+
Optional: true,
185+
Description: "The expected number of instances is synchronized with the maximum and minimum values. The default value is `False`. This parameter is effective only in the scenario where the expected number is not passed in when modifying the scaling group interface. True: When modifying the maximum or minimum value, if there is a conflict with the current expected number, the expected number is adjusted synchronously. For example, when modifying, if the minimum value 2 is passed in and the current expected number is 1, the expected number is adjusted synchronously to 2; False: When modifying the maximum or minimum value, if there is a conflict with the current expected number, an error message is displayed indicating that the modification is not allowed.",
186+
},
177187
"health_check_type": {
178188
Type: schema.TypeString,
179189
Optional: true,
@@ -315,20 +325,28 @@ func resourceTencentCloudAsScalingGroupCreate(d *schema.ResourceData, meta inter
315325
}
316326

317327
var (
318-
scalingMode = d.Get("scaling_mode").(string)
319-
replaceMonitorUnhealthy = d.Get("replace_monitor_unhealthy").(bool)
320-
replaceLBUnhealthy = d.Get("replace_load_balancer_unhealthy").(bool)
328+
replaceMonitorUnhealthy = d.Get("replace_monitor_unhealthy").(bool)
329+
scalingMode = d.Get("scaling_mode").(string)
330+
replaceLBUnhealthy = d.Get("replace_load_balancer_unhealthy").(bool)
331+
replaceMode = d.Get("replace_mode").(string)
332+
desiredCapacitySyncWithMaxMinSize = d.Get("desired_capacity_sync_with_max_min_size").(bool)
321333
)
322334

323-
if scalingMode != "" || replaceMonitorUnhealthy || replaceLBUnhealthy {
335+
if replaceMonitorUnhealthy || scalingMode != "" || replaceLBUnhealthy || replaceMode != "" || desiredCapacitySyncWithMaxMinSize {
324336
if scalingMode == "" {
325337
scalingMode = SCALING_MODE_CLASSIC
326338
}
327339

340+
if replaceMode == "" {
341+
replaceMode = REPLACE_MODE_RECREATE
342+
}
343+
328344
request.ServiceSettings = &as.ServiceSettings{
329-
ScalingMode: &scalingMode,
330-
ReplaceMonitorUnhealthy: &replaceMonitorUnhealthy,
331-
ReplaceLoadBalancerUnhealthy: &replaceLBUnhealthy,
345+
ReplaceMonitorUnhealthy: &replaceMonitorUnhealthy,
346+
ScalingMode: &scalingMode,
347+
ReplaceLoadBalancerUnhealthy: &replaceLBUnhealthy,
348+
ReplaceMode: &replaceMode,
349+
DesiredCapacitySyncWithMaxMinSize: &desiredCapacitySyncWithMaxMinSize,
332350
}
333351
}
334352

@@ -356,8 +374,8 @@ func resourceTencentCloudAsScalingGroupCreate(d *schema.ResourceData, meta inter
356374
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
357375
logId, request.GetAction(), request.ToJsonString(), response.ToJsonString())
358376

359-
if response.Response.AutoScalingGroupId == nil {
360-
err = fmt.Errorf("Auto scaling group id is nil")
377+
if response == nil || response.Response == nil || response.Response.AutoScalingGroupId == nil {
378+
err = fmt.Errorf("Create auto scaling group failed, Auto scaling group id is nil.")
361379
return resource.NonRetryableError(err)
362380
}
363381

@@ -378,7 +396,7 @@ func resourceTencentCloudAsScalingGroupCreate(d *schema.ResourceData, meta inter
378396
if errRet != nil {
379397
return tccommon.RetryError(errRet, tccommon.InternalError)
380398
}
381-
if scalingGroup != nil && *scalingGroup.InActivityStatus == SCALING_GROUP_NOT_IN_ACTIVITY_STATUS {
399+
if scalingGroup != nil && scalingGroup.InActivityStatus != nil && *scalingGroup.InActivityStatus == SCALING_GROUP_NOT_IN_ACTIVITY_STATUS {
382400
return nil
383401
}
384402
return resource.RetryableError(fmt.Errorf("scaling group status is %s, retry...", *scalingGroup.InActivityStatus))
@@ -445,18 +463,26 @@ func resourceTencentCloudAsScalingGroupRead(d *schema.ResourceData, meta interfa
445463
_ = d.Set("multi_zone_subnet_policy", scalingGroup.MultiZoneSubnetPolicy)
446464
}
447465

448-
if v := d.Get("scaling_mode"); v != "" {
449-
_ = d.Set("scaling_mode", v.(string))
450-
}
451-
452466
if v, ok := d.GetOk("replace_monitor_unhealthy"); ok {
453467
_ = d.Set("replace_monitor_unhealthy", v.(bool))
454468
}
455469

470+
if v := d.Get("scaling_mode"); v != "" {
471+
_ = d.Set("scaling_mode", v.(string))
472+
}
473+
456474
if v, ok := d.GetOk("replace_load_balancer_unhealthy"); ok {
457475
_ = d.Set("replace_load_balancer_unhealthy", v.(bool))
458476
}
459477

478+
if v := d.Get("replace_mode"); v != "" {
479+
_ = d.Set("replace_mode", v.(string))
480+
}
481+
482+
if v, ok := d.GetOk("desired_capacity_sync_with_max_min_size"); ok {
483+
_ = d.Set("desired_capacity_sync_with_max_min_size", v.(bool))
484+
}
485+
460486
if scalingGroup.ForwardLoadBalancerSet != nil && len(scalingGroup.ForwardLoadBalancerSet) > 0 {
461487
forwardLoadBalancers := make([]map[string]interface{}, 0, len(scalingGroup.ForwardLoadBalancerSet))
462488
for _, v := range scalingGroup.ForwardLoadBalancerSet {
@@ -578,20 +604,29 @@ func resourceTencentCloudAsScalingGroupUpdate(d *schema.ResourceData, meta inter
578604
request.MultiZoneSubnetPolicy = helper.String(d.Get("multi_zone_subnet_policy").(string))
579605
}
580606

581-
if d.HasChange("scaling_mode") ||
582-
d.HasChange("replace_monitor_unhealthy") ||
583-
d.HasChange("replace_load_balancer_unhealthy") {
584-
updateAttrs = append(updateAttrs, "scaling_mode", "replace_monitor_unhealthy", "replace_load_balancer_unhealthy")
607+
if d.HasChange("replace_monitor_unhealthy") ||
608+
d.HasChange("scaling_mode") ||
609+
d.HasChange("replace_load_balancer_unhealthy") ||
610+
d.HasChange("replace_mode") ||
611+
d.HasChange("desired_capacity_sync_with_max_min_size") {
612+
updateAttrs = append(updateAttrs, "replace_monitor_unhealthy", "scaling_mode", "replace_load_balancer_unhealthy", "replace_mode", "desired_capacity_sync_with_max_min_size")
585613
scalingMode := d.Get("scaling_mode").(string)
614+
replaceMode := d.Get("replace_mode").(string)
586615
if scalingMode == "" {
587616
scalingMode = SCALING_MODE_CLASSIC
588617
}
618+
if replaceMode == "" {
619+
replaceMode = REPLACE_MODE_RECREATE
620+
}
589621
replaceMonitor := d.Get("replace_monitor_unhealthy").(bool)
590622
replaceLB := d.Get("replace_load_balancer_unhealthy").(bool)
623+
desiredCapacitySyncWithMaxMinSize := d.Get("desired_capacity_sync_with_max_min_size").(bool)
591624
request.ServiceSettings = &as.ServiceSettings{
592-
ScalingMode: &scalingMode,
593-
ReplaceMonitorUnhealthy: &replaceMonitor,
594-
ReplaceLoadBalancerUnhealthy: &replaceLB,
625+
ReplaceMonitorUnhealthy: &replaceMonitor,
626+
ScalingMode: &scalingMode,
627+
ReplaceLoadBalancerUnhealthy: &replaceLB,
628+
ReplaceMode: &replaceMode,
629+
DesiredCapacitySyncWithMaxMinSize: &desiredCapacitySyncWithMaxMinSize,
595630
}
596631
}
597632

tencentcloud/services/as/resource_tc_as_scaling_group.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,22 @@ resource "tencentcloud_clb_listener_rule" "example" {
7878
}
7979
8080
resource "tencentcloud_as_scaling_group" "example" {
81-
scaling_group_name = "tf-example"
82-
configuration_id = tencentcloud_as_scaling_config.example.id
83-
max_size = 1
84-
min_size = 0
85-
vpc_id = tencentcloud_vpc.vpc.id
86-
subnet_ids = [tencentcloud_subnet.subnet.id]
87-
project_id = 0
88-
default_cooldown = 400
89-
desired_capacity = 1
90-
termination_policies = ["NEWEST_INSTANCE"]
91-
retry_policy = "INCREMENTAL_INTERVALS"
81+
scaling_group_name = "tf-example"
82+
configuration_id = tencentcloud_as_scaling_config.example.id
83+
max_size = 1
84+
min_size = 0
85+
vpc_id = tencentcloud_vpc.vpc.id
86+
subnet_ids = [tencentcloud_subnet.subnet.id]
87+
project_id = 0
88+
default_cooldown = 400
89+
desired_capacity = 1
90+
replace_monitor_unhealthy = false
91+
scaling_mode = "CLASSIC_SCALING"
92+
replace_load_balancer_unhealthy = false
93+
replace_mode = "RECREATE"
94+
desired_capacity_sync_with_max_min_size = false
95+
termination_policies = ["NEWEST_INSTANCE"]
96+
retry_policy = "INCREMENTAL_INTERVALS"
9297
9398
forward_balancer_ids {
9499
load_balancer_id = tencentcloud_clb_instance.example.id
@@ -102,7 +107,7 @@ resource "tencentcloud_as_scaling_group" "example" {
102107
}
103108
104109
tags = {
105-
"createBy" = "tfExample"
110+
createBy = "tfExample"
106111
}
107112
}
108113
```
@@ -112,5 +117,5 @@ Import
112117
AutoScaling Groups can be imported using the id, e.g.
113118

114119
```
115-
$ terraform import tencentcloud_as_scaling_group.scaling_group asg-n32ymck2
120+
$ terraform import tencentcloud_as_scaling_group.example asg-n32ymck2
116121
```

tencentcloud/services/as/service_tencentcloud_as.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,9 @@ func (me *AsService) DescribeAutoScalingGroupById(ctx context.Context, scalingGr
118118
errRet = err
119119
return
120120
}
121+
if response == nil || response.Response == nil || response.Response.AutoScalingGroupSet == nil {
122+
return
123+
}
121124
has = len(response.Response.AutoScalingGroupSet)
122125
if has < 1 {
123126
return

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as/v20180419/models.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/http/request.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway/v20180808
11061106
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825
11071107
## explicit; go 1.14
11081108
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm/v20210622
1109-
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1052
1109+
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.0.1071
11101110
## explicit; go 1.14
11111111
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as/v20180419
11121112
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824
@@ -1163,7 +1163,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319
11631163
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1046
11641164
## explicit; go 1.14
11651165
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016
1166-
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1068
1166+
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.0.1071
11671167
## explicit; go 1.11
11681168
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common
11691169
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors

0 commit comments

Comments
 (0)