Skip to content

Commit 7ba9d18

Browse files
authored
add LCU clb (#2304)
* add LCU clb * add changelog
1 parent f09ec1b commit 7ba9d18

File tree

5 files changed

+104
-4
lines changed

5 files changed

+104
-4
lines changed

.changelog/2304.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_clb_instance: Support set `sla_type` field.
3+
```

tencentcloud/resource_tc_clb_instance.go

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ resource "tencentcloud_clb_instance" "internal_clb" {
1919
}
2020
```
2121
22+
LCU-supported CLB
23+
24+
```hcl
25+
resource "tencentcloud_clb_instance" "internal_clb" {
26+
network_type = "INTERNAL"
27+
clb_name = "myclb"
28+
project_id = 0
29+
sla_type = "clb.c3.medium"
30+
vpc_id = "vpc-2hfyray3"
31+
subnet_id = "subnet-o3a5nt20"
32+
33+
tags = {
34+
test = "tf"
35+
}
36+
}
37+
```
38+
2239
OPEN CLB
2340
2441
```hcl
@@ -320,6 +337,21 @@ func resourceTencentCloudClbInstance() *schema.Resource {
320337
Optional: true,
321338
Description: "The available tags within this CLB.",
322339
},
340+
"sla_type": {
341+
Type: schema.TypeString,
342+
Optional: true,
343+
Computed: true,
344+
Description: "This parameter is required to create LCU-supported instances. Values:" +
345+
"`SLA`: Super Large 4. When you have activated Super Large models, `SLA` refers to Super Large 4; " +
346+
"`clb.c2.medium`: Standard; " +
347+
"`clb.c3.small`: Advanced 1; " +
348+
"`clb.c3.medium`: Advanced 1; " +
349+
"`clb.c4.small`: Super Large 1; " +
350+
"`clb.c4.medium`: Super Large 2; " +
351+
"`clb.c4.large`: Super Large 3; " +
352+
"`clb.c4.xlarge`: Super Large 4. " +
353+
"For more details, see [Instance Specifications](https://intl.cloud.tencent.com/document/product/214/84689?from_cn_redirect=1).",
354+
},
323355
"vip_isp": {
324356
Type: schema.TypeString,
325357
Computed: true,
@@ -430,6 +462,11 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
430462
request.VipIsp = helper.String(v.(string))
431463
}
432464

465+
//SlaType
466+
if v, ok := d.GetOk("sla_type"); ok {
467+
request.SlaType = helper.String(v.(string))
468+
}
469+
433470
//ip version
434471
if v, ok := d.GetOk("address_ip_version"); ok {
435472
if networkType == CLB_NETWORK_TYPE_INTERNAL {
@@ -718,6 +755,9 @@ func resourceTencentCloudClbInstanceRead(d *schema.ResourceData, meta interface{
718755
_ = d.Set("security_groups", helper.StringsInterfaces(instance.SecureGroups))
719756
_ = d.Set("domain", instance.LoadBalancerDomain)
720757

758+
if instance.SlaType != nil {
759+
_ = d.Set("sla_type", instance.SlaType)
760+
}
721761
if instance.VipIsp != nil {
722762
_ = d.Set("vip_isp", instance.VipIsp)
723763
}
@@ -862,6 +902,36 @@ func resourceTencentCloudClbInstanceUpdate(d *schema.ResourceData, meta interfac
862902
}
863903
}
864904

905+
if d.HasChange("sla_type") {
906+
slaRequest := clb.NewModifyLoadBalancerSlaRequest()
907+
param := clb.SlaUpdateParam{}
908+
param.LoadBalancerId = &clbId
909+
param.SlaType = helper.String(d.Get("sla_type").(string))
910+
911+
slaRequest.LoadBalancerSla = []*clb.SlaUpdateParam{&param}
912+
913+
var taskId string
914+
err := resource.Retry(writeRetryTimeout, func() *resource.RetryError {
915+
result, e := meta.(*TencentCloudClient).apiV3Conn.UseClbClient().ModifyLoadBalancerSla(slaRequest)
916+
if e != nil {
917+
return retryError(e)
918+
} else {
919+
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n", logId, request.GetAction(), request.ToJsonString(), result.ToJsonString())
920+
}
921+
taskId = *result.Response.RequestId
922+
return nil
923+
})
924+
if err != nil {
925+
log.Printf("[CRITAL]%s update clb instanceSlaConfig failed, reason:%+v", logId, err)
926+
return err
927+
}
928+
929+
retryErr := waitForTaskFinish(taskId, meta.(*TencentCloudClient).apiV3Conn.UseClbClient())
930+
if retryErr != nil {
931+
return retryErr
932+
}
933+
}
934+
865935
if d.HasChange("security_groups") {
866936

867937
sgRequest := clb.NewSetLoadBalancerSecurityGroupsRequest()

tencentcloud/resource_tc_clb_instance_sla_config.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,18 @@ func resourceTencentCloudClbInstanceSlaConfig() *schema.Resource {
4646
Description: "ID of the CLB instance.",
4747
},
4848
"sla_type": {
49-
Type: schema.TypeString,
50-
Required: true,
51-
Description: "To upgrade to LCU-supported CLB instances. It must be SLA.",
49+
Type: schema.TypeString,
50+
Required: true,
51+
Description: "This parameter is required to create LCU-supported instances. Values:" +
52+
"`SLA`: Super Large 4. When you have activated Super Large models, `SLA` refers to Super Large 4; " +
53+
"`clb.c2.medium`: Standard; " +
54+
"`clb.c3.small`: Advanced 1; " +
55+
"`clb.c3.medium`: Advanced 1; " +
56+
"`clb.c4.small`: Super Large 1; " +
57+
"`clb.c4.medium`: Super Large 2; " +
58+
"`clb.c4.large`: Super Large 3; " +
59+
"`clb.c4.xlarge`: Super Large 4. " +
60+
"For more details, see [Instance Specifications](https://intl.cloud.tencent.com/document/product/214/84689?from_cn_redirect=1).",
5261
},
5362
},
5463
}

website/docs/r/clb_instance.html.markdown

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ resource "tencentcloud_clb_instance" "internal_clb" {
2929
}
3030
```
3131

32+
### LCU-supported CLB
33+
34+
```hcl
35+
resource "tencentcloud_clb_instance" "internal_clb" {
36+
network_type = "INTERNAL"
37+
clb_name = "myclb"
38+
project_id = 0
39+
sla_type = "clb.c3.medium"
40+
vpc_id = "vpc-2hfyray3"
41+
subnet_id = "subnet-o3a5nt20"
42+
43+
tags = {
44+
test = "tf"
45+
}
46+
}
47+
```
48+
3249
### OPEN CLB
3350

3451
```hcl
@@ -197,6 +214,7 @@ The following arguments are supported:
197214
* `master_zone_id` - (Optional, String) Setting master zone id of cross available zone disaster recovery, only applicable to open CLB.
198215
* `project_id` - (Optional, Int, ForceNew) ID of the project within the CLB instance, `0` - Default Project.
199216
* `security_groups` - (Optional, List: [`String`]) Security groups of the CLB instance. Supports both `OPEN` and `INTERNAL` CLBs.
217+
* `sla_type` - (Optional, String) This parameter is required to create LCU-supported instances. Values:`SLA`: Super Large 4. When you have activated Super Large models, `SLA` refers to Super Large 4; `clb.c2.medium`: Standard; `clb.c3.small`: Advanced 1; `clb.c3.medium`: Advanced 1; `clb.c4.small`: Super Large 1; `clb.c4.medium`: Super Large 2; `clb.c4.large`: Super Large 3; `clb.c4.xlarge`: Super Large 4. For more details, see [Instance Specifications](https://intl.cloud.tencent.com/document/product/214/84689?from_cn_redirect=1).
200218
* `slave_zone_id` - (Optional, String) Setting slave zone id of cross available zone disaster recovery, only applicable to open CLB. this zone will undertake traffic when the master is down.
201219
* `snat_ips` - (Optional, List) Snat Ip List, required with `snat_pro=true`. NOTE: This argument cannot be read and modified here because dynamic ip is untraceable, please import resource `tencentcloud_clb_snat_ip` to handle fixed ips.
202220
* `snat_pro` - (Optional, Bool) Indicates whether Binding IPs of other VPCs feature switch.

website/docs/r/clb_instance_sla_config.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ resource "tencentcloud_clb_instance_sla_config" "instance_sla_config" {
2525
The following arguments are supported:
2626

2727
* `load_balancer_id` - (Required, String) ID of the CLB instance.
28-
* `sla_type` - (Required, String) To upgrade to LCU-supported CLB instances. It must be SLA.
28+
* `sla_type` - (Required, String) This parameter is required to create LCU-supported instances. Values:`SLA`: Super Large 4. When you have activated Super Large models, `SLA` refers to Super Large 4; `clb.c2.medium`: Standard; `clb.c3.small`: Advanced 1; `clb.c3.medium`: Advanced 1; `clb.c4.small`: Super Large 1; `clb.c4.medium`: Super Large 2; `clb.c4.large`: Super Large 3; `clb.c4.xlarge`: Super Large 4. For more details, see [Instance Specifications](https://intl.cloud.tencent.com/document/product/214/84689?from_cn_redirect=1).
2929

3030
## Attributes Reference
3131

0 commit comments

Comments
 (0)