Skip to content

Commit c4a110b

Browse files
authored
Merge pull request #703 from tencentcloudstack/fix/clb-bandwidth-pkg-id
fix: clb - support bandwidth_package_id
2 parents cdcf88f + 9a4a96f commit c4a110b

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

tencentcloud/resource_tc_clb_instance.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ func resourceTencentCloudClbInstance() *schema.Resource {
179179
Computed: true,
180180
Description: "Internet charge type, only applicable to open CLB. Valid values are `TRAFFIC_POSTPAID_BY_HOUR`, `BANDWIDTH_POSTPAID_BY_HOUR` and `BANDWIDTH_PACKAGE`.",
181181
},
182+
"bandwidth_package_id": {
183+
Type: schema.TypeString,
184+
Optional: true,
185+
Description: "Bandwidth package id. If set, the `internet_charge_type` must be `BANDWIDTH_PACKAGE`.",
186+
},
182187
"internet_bandwidth_max_out": {
183188
Type: schema.TypeInt,
184189
Optional: true,
@@ -308,6 +313,9 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
308313

309314
v, ok := d.GetOk("internet_charge_type")
310315
bv, bok := d.GetOk("internet_bandwidth_max_out")
316+
pv, pok := d.GetOk("bandwidth_package_id")
317+
318+
chargeType := v.(string)
311319

312320
//internet charge type
313321
if ok || bok {
@@ -316,11 +324,19 @@ func resourceTencentCloudClbInstanceCreate(d *schema.ResourceData, meta interfac
316324
}
317325
request.InternetAccessible = &clb.InternetAccessible{}
318326
if ok {
319-
request.InternetAccessible.InternetChargeType = helper.String(v.(string))
327+
request.InternetAccessible.InternetChargeType = helper.String(chargeType)
320328
}
321329
if bok {
322330
request.InternetAccessible.InternetMaxBandwidthOut = helper.IntInt64(bv.(int))
323331
}
332+
if pok {
333+
if pok && chargeType != INTERNET_CHARGE_TYPE_BANDWIDTH_PACKAGE {
334+
return fmt.Errorf("[CHECK][CLB instance][Create] check: internet_charge_type must `BANDWIDTH_PACKAGE` when bandwidth_package_id was set")
335+
}
336+
request.BandwidthPackageId = helper.String(pv.(string))
337+
} else if chargeType == INTERNET_CHARGE_TYPE_BANDWIDTH_PACKAGE {
338+
return fmt.Errorf("[CHECK][CLB instance][Create] check: the `bandwidth_package_id` must be specified if internet_charge_type was `BANDWIDTH_PACKAGE`")
339+
}
324340
}
325341

326342
if v, ok := d.GetOk("master_zone_id"); ok {

website/docs/r/clb_instance.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ The following arguments are supported:
108108
* `clb_name` - (Required) Name of the CLB. The name can only contain Chinese characters, English letters, numbers, underscore and hyphen '-'.
109109
* `network_type` - (Required, ForceNew) Type of CLB instance. Valid values: `OPEN` and `INTERNAL`.
110110
* `address_ip_version` - (Optional) IP version, only applicable to open CLB. Valid values are `ipv4`, `ipv6` and `IPv6FullChain`.
111+
* `bandwidth_package_id` - (Optional) Bandwidth package id. If set, the `internet_charge_type` must be `BANDWIDTH_PACKAGE`.
111112
* `internet_bandwidth_max_out` - (Optional) Max bandwidth out, only applicable to open CLB. Valid value ranges is [1, 2048]. Unit is MB.
112113
* `internet_charge_type` - (Optional) Internet charge type, only applicable to open CLB. Valid values are `TRAFFIC_POSTPAID_BY_HOUR`, `BANDWIDTH_POSTPAID_BY_HOUR` and `BANDWIDTH_PACKAGE`.
113114
* `load_balancer_pass_to_target` - (Optional) Whether the target allow flow come from clb. If value is true, only check security group of clb, or check both clb and backend instance security group.

0 commit comments

Comments
 (0)