Skip to content

Commit 8451aa1

Browse files
authored
fix(as): [128286566] tencentcloud_as_scaling_policy add new params (#3582)
* add * add * add
1 parent 96a7e38 commit 8451aa1

File tree

9 files changed

+113
-10
lines changed

9 files changed

+113
-10
lines changed

.changelog/3582.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_as_scaling_policy: add new params
3+
```

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.1.21
33+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.48
3434
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824
3535
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cam v1.1.27
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.1107
4747
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit v1.0.1033
4848
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1148
49-
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.46
49+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.48
5050
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm v1.0.1206
5151
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cwp v1.0.762
5252
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cynosdb v1.0.1161

go.sum

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.4 h1:9EguBiOzGy
831831
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.4/go.mod h1:jUF68ck1rxCqXkdmYRT2B2GtLrXAxmp7T0CcyWZ8BbM=
832832
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.21 h1:Y1miKK/dhfGn3AtCXMFDE3+kOUXyJMUnVlHCGC6EKSw=
833833
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.21/go.mod h1:JqVqVFUzcEVksJT1WNRUsRQPgyfLSpJ8C0PxnTXinuY=
834+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.48 h1:pBJSevHHm4vqF3gM7NcqSSPmzvgAlGRoHapUkbcJTzQ=
835+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.48/go.mod h1:Qqv7rukVdZ8hZzIOQ02IxFgFbjOAWg+B7KNrYZG5MOA=
834836
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824 h1:DVKvZ6h+qd7tadUrCjVAkCCmE3TsbK2ZmwGd3AJcpWc=
835837
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824/go.mod h1:DvBpDX/qdJG4KKLeULmRvhAjPYiw8za0HeTSu2y/lFw=
836838
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/billing v1.1.0 h1:tfTh+fIqYPgWV2wi4oDvG963pi8tljtZ+5OdnhEqRnU=
@@ -970,6 +972,8 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.45 h1:aHdlX
970972
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.45/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
971973
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.46 h1:wWcfc+d0BJSGvLtIdPSLuN//KCgIhuWbjao68roZrzw=
972974
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.46/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
975+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.48 h1:aoRUrz2ag27jQWcOKHgeE+toSti6/xPqHKMLruOtJuM=
976+
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.48/go.mod h1:r5r4xbfxSaeR04b166HGsBa/R4U3SueirEUpXGuw+Q0=
973977
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993 h1:WlPgXldQCxt7qi5Xrc6j6zTrsXWzN5BcOGs7Irq7fwQ=
974978
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/controlcenter v1.0.993/go.mod h1:Z9U8zNtyuyKhjS0698wqsrG/kLx1TQ5CEixXBwVe7xY=
975979
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/csip v1.0.860 h1:F3esKBIT3HW9+7Gt8cVgf8X06VdGIczpgLBUECzSEzU=

tencentcloud/services/as/resource_tc_as_scaling_policy.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,37 @@ func ResourceTencentCloudAsScalingPolicy() *schema.Resource {
8989
"notification_user_group_ids": {
9090
Type: schema.TypeList,
9191
Optional: true,
92+
Computed: true,
9293
Elem: &schema.Schema{Type: schema.TypeString},
9394
Description: "An ID group of users to be notified when an alarm is triggered.",
9495
},
96+
"policy_type": {
97+
Type: schema.TypeString,
98+
Optional: true,
99+
ForceNew: true,
100+
Computed: true,
101+
Description: "Alarm triggering policy type, the default type is SIMPLE. Value range: SIMPLE: Simple policy; TARGET_TRACKING: Target tracking policy.",
102+
},
103+
"predefined_metric_type": {
104+
Type: schema.TypeString,
105+
Optional: true,
106+
Description: "Predefined monitoring items, applicable only to target tracking policies, and required in target tracking policy scenarios. Value range: ASG_AVG_CPU_UTILIZATION: Average CPU utilization; ASG_AVG_LAN_TRAFFIC_OUT: Average intranet outbound bandwidth; ASG_AVG_LAN_TRAFFIC_IN: Average intranet inbound bandwidth; ASG_AVG_WAN_TRAFFIC_OUT: Average internet outbound bandwidth; ASG_AVG_WAN_TRAFFIC_IN: Average internet inbound bandwidth.",
107+
},
108+
"target_value": {
109+
Type: schema.TypeInt,
110+
Optional: true,
111+
Description: "Target value, applicable only to target tracking strategies, and required in target tracking strategy scenarios. ASG_AVG_CPU_UTILIZATION: [1, 100), Unit: %; ASG_AVG_LAN_TRAFFIC_OUT: >0, Unit: Mbps; ASG_AVG_LAN_TRAFFIC_IN: >0, Unit: Mbps; ASG_AVG_WAN_TRAFFIC_OUT: >0, Unit: Mbps; ASG_AVG_WAN_TRAFFIC_IN: >0, Unit: Mbps.",
112+
},
113+
"estimated_instance_warmup": {
114+
Type: schema.TypeInt,
115+
Optional: true,
116+
Description: "Instance warm-up time, in seconds, applicable only to target tracking strategies. Value range is 0-3600, with a default warm-up time of 300 seconds.",
117+
},
118+
"disable_scale_in": {
119+
Type: schema.TypeBool,
120+
Optional: true,
121+
Description: "Whether to disable scaling down applies only to the target tracking strategy; the default value is false. Value range: true: The target tracking strategy only triggers scaling up; false: The target tracking strategy triggers both scaling up and scaling down.",
122+
},
95123
},
96124
}
97125
}
@@ -128,6 +156,26 @@ func resourceTencentCloudAsScalingPolicyCreate(d *schema.ResourceData, meta inte
128156
}
129157
}
130158

159+
if v, ok := d.GetOk("policy_type"); ok {
160+
request.ScalingPolicyType = helper.String(v.(string))
161+
}
162+
163+
if v, ok := d.GetOk("predefined_metric_type"); ok {
164+
request.PredefinedMetricType = helper.String(v.(string))
165+
}
166+
167+
if v, ok := d.GetOkExists("target_value"); ok {
168+
request.TargetValue = helper.IntUint64(v.(int))
169+
}
170+
171+
if v, ok := d.GetOkExists("estimated_instance_warmup"); ok {
172+
request.EstimatedInstanceWarmup = helper.IntUint64(v.(int))
173+
}
174+
175+
if v, ok := d.GetOkExists("disable_scale_in"); ok {
176+
request.DisableScaleIn = helper.Bool(v.(bool))
177+
}
178+
131179
response, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseAsClient().CreateScalingPolicy(request)
132180
if err != nil {
133181
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
@@ -204,6 +252,21 @@ func resourceTencentCloudAsScalingPolicyRead(d *schema.ResourceData, meta interf
204252
if scalingPolicy.NotificationUserGroupIds != nil {
205253
_ = d.Set("notification_user_group_ids", helper.StringsInterfaces(scalingPolicy.NotificationUserGroupIds))
206254
}
255+
if scalingPolicy.ScalingPolicyType != nil {
256+
_ = d.Set("policy_type", *scalingPolicy.ScalingPolicyType)
257+
}
258+
if scalingPolicy.PredefinedMetricType != nil {
259+
_ = d.Set("predefined_metric_type", *scalingPolicy.PredefinedMetricType)
260+
}
261+
if scalingPolicy.TargetValue != nil {
262+
_ = d.Set("target_value", *scalingPolicy.TargetValue)
263+
}
264+
if scalingPolicy.EstimatedInstanceWarmup != nil {
265+
_ = d.Set("estimated_instance_warmup", *scalingPolicy.EstimatedInstanceWarmup)
266+
}
267+
if scalingPolicy.DisableScaleIn != nil {
268+
_ = d.Set("disable_scale_in", *scalingPolicy.DisableScaleIn)
269+
}
207270
return nil
208271
})
209272
if err != nil {
@@ -250,6 +313,22 @@ func resourceTencentCloudAsScalingPolicyUpdate(d *schema.ResourceData, meta inte
250313
}
251314
}
252315

316+
if v, ok := d.GetOk("predefined_metric_type"); ok {
317+
request.PredefinedMetricType = helper.String(v.(string))
318+
}
319+
320+
if v, ok := d.GetOkExists("target_value"); ok {
321+
request.TargetValue = helper.IntUint64(v.(int))
322+
}
323+
324+
if v, ok := d.GetOkExists("estimated_instance_warmup"); ok {
325+
request.EstimatedInstanceWarmup = helper.IntUint64(v.(int))
326+
}
327+
328+
if v, ok := d.GetOkExists("disable_scale_in"); ok {
329+
request.DisableScaleIn = helper.Bool(v.(bool))
330+
}
331+
253332
response, err := meta.(tccommon.ProviderMeta).GetAPIV3Conn().UseAsClient().ModifyScalingPolicy(request)
254333
if err != nil {
255334
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",

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

Lines changed: 4 additions & 4 deletions
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/as/v20180419/models.go

Lines changed: 13 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
@@ -1110,7 +1110,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apigateway/v20180808
11101110
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm v1.0.825
11111111
## explicit; go 1.14
11121112
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/apm/v20210622
1113-
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.21
1113+
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as v1.1.48
11141114
## explicit; go 1.14
11151115
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/as/v20180419
11161116
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/bi v1.0.824
@@ -1170,7 +1170,7 @@ github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cloudaudit/v20190319
11701170
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls v1.0.1148
11711171
## explicit; go 1.14
11721172
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cls/v20201016
1173-
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.46
1173+
# github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common v1.1.48
11741174
## explicit; go 1.11
11751175
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common
11761176
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors

website/docs/r/as_scaling_policy.html.markdown

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,13 @@ The following arguments are supported:
8282
* `scaling_group_id` - (Required, String, ForceNew) ID of a scaling group.
8383
* `threshold` - (Required, Int) Alarm threshold.
8484
* `cooldown` - (Optional, Int) Cooldwon time in second. Default is `30`0.
85+
* `disable_scale_in` - (Optional, Bool) Whether to disable scaling down applies only to the target tracking strategy; the default value is false. Value range: true: The target tracking strategy only triggers scaling up; false: The target tracking strategy triggers both scaling up and scaling down.
86+
* `estimated_instance_warmup` - (Optional, Int) Instance warm-up time, in seconds, applicable only to target tracking strategies. Value range is 0-3600, with a default warm-up time of 300 seconds.
8587
* `notification_user_group_ids` - (Optional, List: [`String`]) An ID group of users to be notified when an alarm is triggered.
88+
* `policy_type` - (Optional, String, ForceNew) Alarm triggering policy type, the default type is SIMPLE. Value range: SIMPLE: Simple policy; TARGET_TRACKING: Target tracking policy.
89+
* `predefined_metric_type` - (Optional, String) Predefined monitoring items, applicable only to target tracking policies, and required in target tracking policy scenarios. Value range: ASG_AVG_CPU_UTILIZATION: Average CPU utilization; ASG_AVG_LAN_TRAFFIC_OUT: Average intranet outbound bandwidth; ASG_AVG_LAN_TRAFFIC_IN: Average intranet inbound bandwidth; ASG_AVG_WAN_TRAFFIC_OUT: Average internet outbound bandwidth; ASG_AVG_WAN_TRAFFIC_IN: Average internet inbound bandwidth.
8690
* `statistic` - (Optional, String) Statistic types. Valid values: `AVERAGE`, `MAXIMUM` and `MINIMUM`. Default is `AVERAGE`.
91+
* `target_value` - (Optional, Int) Target value, applicable only to target tracking strategies, and required in target tracking strategy scenarios. ASG_AVG_CPU_UTILIZATION: [1, 100), Unit: %; ASG_AVG_LAN_TRAFFIC_OUT: >0, Unit: Mbps; ASG_AVG_LAN_TRAFFIC_IN: >0, Unit: Mbps; ASG_AVG_WAN_TRAFFIC_OUT: >0, Unit: Mbps; ASG_AVG_WAN_TRAFFIC_IN: >0, Unit: Mbps.
8792

8893
## Attributes Reference
8994

0 commit comments

Comments
 (0)