Skip to content

Commit 20bd7fd

Browse files
committed
fix:resource_instance bugs
1 parent 25997b9 commit 20bd7fd

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ BUG FIXES:
55
* Resource: `tencentcloud_vpn_gateway` fix force new issue when apply repeatedly.
66
* Resource: `tencentcloud_vpn_connection` fix force new issue when apply repeatedly.
77

8+
ENHANCEMENTS:
9+
10+
* Resource: `tencentcloud_instance` support for adjusting `internet_max_bandwidth_out` without forceNew when attribute `internet_charge_type` within `TRAFFIC_POSTPAID_BY_HOUR` `BANDWIDTH_POSTPAID_BY_HOUR` `BANDWIDTH_PACKAGE`.
11+
812
## 1.41.0 (August 17, 2020)
913

1014
FEATURES:

tencentcloud/resource_tc_instance.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -943,15 +943,17 @@ func resourceTencentCloudInstanceUpdate(d *schema.ResourceData, meta interface{}
943943
}
944944

945945
if d.HasChange("internet_max_bandwidth_out") {
946-
if chargeType := d.Get("internet_charge_type").(string); chargeType != "TRAFFIC_POSTPAID_BY_HOUR" && chargeType != "BANDWIDTH_POSTPAID_BY_HOUR" && chargeType != "BANDWIDTH_PACKAGE" {
947-
return fmt.Errorf("bad internet_charge_type.type should be in: TRAFFIC_POSTPAID_BY_HOUR BANDWIDTH_POSTPAID_BY_HOUR BANDWIDTH_PACKAGE")
946+
chargeType := d.Get("internet_charge_type").(string)
947+
if chargeType != "TRAFFIC_POSTPAID_BY_HOUR" && chargeType != "BANDWIDTH_POSTPAID_BY_HOUR" && chargeType != "BANDWIDTH_PACKAGE" {
948+
return fmt.Errorf("charge type should be one of `TRAFFIC_POSTPAID_BY_HOUR BANDWIDTH_POSTPAID_BY_HOUR BANDWIDTH_PACKAGE` when adjusting internet_max_bandwidth_out")
948949
}
949950

950-
err := cvmService.ModifyInternetMaxBandwidthOut(ctx, instanceId, d.Get("internet_charge_type").(string), d.Get("internet_max_bandwidth_out").(int64))
951+
err := cvmService.ModifyInternetMaxBandwidthOut(ctx, instanceId, chargeType, int64(d.Get("internet_max_bandwidth_out").(int)))
951952
if err != nil {
952953
return err
953954
}
954955
d.SetPartial("internet_max_bandwidth_out")
956+
time.Sleep(1 * time.Second)
955957
err = resource.Retry(2*readRetryTimeout, func() *resource.RetryError {
956958
instance, errRet := cvmService.DescribeInstanceById(ctx, instanceId)
957959
if errRet != nil {

website/docs/r/instance.html.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ The following arguments are supported:
9292
* `instance_name` - (Optional) The name of the CVM. The max length of instance_name is 60, and default value is `Terraform-CVM-Instance`.
9393
* `instance_type` - (Optional) The type of instance to start.
9494
* `internet_charge_type` - (Optional, ForceNew) Internet charge type of the instance, Valid values are `BANDWIDTH_PREPAID`, `TRAFFIC_POSTPAID_BY_HOUR`, `BANDWIDTH_POSTPAID_BY_HOUR` and `BANDWIDTH_PACKAGE`. This value does not need to be set when `allocate_public_ip` is false.
95-
* `internet_max_bandwidth_out` - (Optional, ForceNew) Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). This value does not need to be set when `allocate_public_ip` is false.
95+
* `internet_max_bandwidth_out` - (Optional) Maximum outgoing bandwidth to the public network, measured in Mbps (Mega bit per second). This value does not need to be set when `allocate_public_ip` is false.
9696
* `key_name` - (Optional) The key pair to use for the instance, it looks like skey-16jig7tx.
9797
* `password` - (Optional) Password to an instance. In order to take effect new password, the instance will be restarted after modifying the password.
9898
* `placement_group_id` - (Optional, ForceNew) The id of a placement group.

0 commit comments

Comments
 (0)