Skip to content

Commit 9c0d47b

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents cd1ba10 + 4269573 commit 9c0d47b

File tree

7 files changed

+40
-2
lines changed

7 files changed

+40
-2
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
## 1.53.8 (Unreleased)
2+
3+
ENHANCEMENTS:
4+
5+
* Resource `tencentcloud_instance` add `cam_role_name` to support binding role to cvm instance.
6+
7+
BUG FIXES:
8+
9+
* Resource `tencentcloud_instance` fix bug that waiting 5 minutes when cloud disk sold out.
10+
* Resource: `tencentcloud_tcr_instance` fix bug that only one tag is effective when setting multiple tags.
11+
212
## 1.53.7 (March 10, 2021)
313

414
ENHANCEMENTS:

tencentcloud/data_source_tc_instances.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ func dataSourceTencentCloudInstances() *schema.Resource {
231231
Computed: true,
232232
Description: "The way that CVM instance will be renew automatically or not when it reach the end of the prepaid tenancy.",
233233
},
234+
"cam_role_name": {
235+
Type: schema.TypeString,
236+
Computed: true,
237+
Description: "CAM role name authorized to access.",
238+
},
234239
},
235240
},
236241
},
@@ -311,6 +316,7 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
311316
"create_time": instance.CreatedTime,
312317
"expired_time": instance.ExpiredTime,
313318
"instance_charge_type_prepaid_renew_flag": instance.RenewFlag,
319+
"cam_role_name": instance.CamRoleName,
314320
}
315321
if len(instance.PublicIpAddresses) > 0 {
316322
mapping["public_ip"] = *instance.PublicIpAddresses[0]

tencentcloud/extension_cvm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ const (
4848
CVM_IMAGE_LOGIN = "TRUE"
4949
CVM_IMAGE_LOGIN_NOT = "FALSE"
5050

51-
CVM_ZONE_NOT_SUPPORT_ERROR = "InvalidParameterValue.ZoneNotSupported"
51+
CVM_ZONE_NOT_SUPPORT_ERROR = "InvalidParameterValue.ZoneNotSupported"
52+
CVM_CLOUD_DISK_SOLD_OUT_ERROR = "ResourceInsufficient.CloudDiskSoldOut"
5253
)
5354

5455
var CVM_CHARGE_TYPE = []string{

tencentcloud/resource_tc_instance.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ resource "tencentcloud_instance" "my_awesome_app" {
5353
subnet_id = tencentcloud_subnet.app.id
5454
internet_max_bandwidth_out = 20
5555
count = 2
56+
cam_role_name = "CVM_QcsRole"
5657
5758
data_disks {
5859
data_disk_type = "CLOUD_PREMIUM"
@@ -87,6 +88,7 @@ import (
8788
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
8889
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
8990
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
91+
sdkErrors "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
9092
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
9193
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/internal/helper"
9294
"github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/ratelimit"
@@ -383,6 +385,13 @@ func resourceTencentCloudInstance() *schema.Resource {
383385
Default: false,
384386
Description: "Indicate whether to force delete the instance. Default is `false`. If set true, the instance will be permanently deleted instead of being moved into the recycle bin. Note: only works for `PREPAID` instance.",
385387
},
388+
// role
389+
"cam_role_name": {
390+
Type: schema.TypeString,
391+
ForceNew: true,
392+
Optional: true,
393+
Description: "CAM role name authorized to access.",
394+
},
386395
// Computed values.
387396
"instance_status": {
388397
Type: schema.TypeString,
@@ -434,6 +443,9 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
434443
if v, ok := d.GetOk("hostname"); ok {
435444
request.HostName = helper.String(v.(string))
436445
}
446+
if v, ok := d.GetOk("cam_role_name"); ok {
447+
request.CamRoleName = helper.String(v.(string))
448+
}
437449

438450
if v, ok := d.GetOk("instance_charge_type"); ok {
439451
instanceChargeType := v.(string)
@@ -599,6 +611,10 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
599611
if err != nil {
600612
log.Printf("[CRITAL]%s api[%s] fail, request body [%s], reason[%s]\n",
601613
logId, request.GetAction(), request.ToJsonString(), err.Error())
614+
e, ok := err.(*sdkErrors.TencentCloudSDKError)
615+
if ok && e.Code == CVM_CLOUD_DISK_SOLD_OUT_ERROR {
616+
return resource.NonRetryableError(e)
617+
}
602618
return retryError(err)
603619
}
604620
log.Printf("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n",
@@ -775,6 +791,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
775791
_ = d.Set("instance_status", instance.InstanceState)
776792
_ = d.Set("create_time", instance.CreatedTime)
777793
_ = d.Set("expired_time", instance.ExpiredTime)
794+
_ = d.Set("cam_role_name", instance.CamRoleName)
778795

779796
if _, ok := d.GetOkExists("allocate_public_ip"); !ok {
780797
_ = d.Set("allocate_public_ip", len(instance.PublicIpAddresses) > 0)

tencentcloud/service_tencentcloud_tcr.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ func (me *TCRService) CreateTCRInstance(ctx context.Context, name string, instan
3030
if len(tags) > 0 {
3131
tagSpec := tcr.TagSpecification{ResourceType: helper.String("instance"), Tags: make([]*tcr.Tag, 0)}
3232
for k, v := range tags {
33-
tag := tcr.Tag{Value: &v, Key: &k}
33+
key, value := k, v
34+
tag := tcr.Tag{Value: &value, Key: &key}
3435
tagSpec.Tags = append(tagSpec.Tags, &tag)
3536
}
3637
request.TagSpecification = &tagSpec

website/docs/d/instances.html.markdown

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ In addition to all arguments above, the following attributes are exported:
3939
* `instance_list` - An information list of cvm instance. Each element contains the following attributes:
4040
* `allocate_public_ip` - Indicates whether public ip is assigned.
4141
* `availability_zone` - The available zone that the CVM instance locates at.
42+
* `cam_role_name` - CAM role name authorized to access.
4243
* `cpu` - The number of CPU cores of the instance.
4344
* `create_time` - Creation time of the instance.
4445
* `data_disks` - An information list of data disk. Each element contains the following attributes:

website/docs/r/instance.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ resource "tencentcloud_instance" "my_awesome_app" {
6363
subnet_id = tencentcloud_subnet.app.id
6464
internet_max_bandwidth_out = 20
6565
count = 2
66+
cam_role_name = "CVM_QcsRole"
6667
6768
data_disks {
6869
data_disk_type = "CLOUD_PREMIUM"
@@ -83,6 +84,7 @@ The following arguments are supported:
8384
* `availability_zone` - (Required, ForceNew) The available zone for the CVM instance.
8485
* `image_id` - (Required, ForceNew) The image to use for the instance. Changing `image_id` will cause the instance to be destroyed and re-created.
8586
* `allocate_public_ip` - (Optional, ForceNew) Associate a public IP address with an instance in a VPC or Classic. Boolean value, Default is false.
87+
* `cam_role_name` - (Optional, ForceNew) CAM role name authorized to access.
8688
* `data_disks` - (Optional, ForceNew) Settings for data disks.
8789
* `disable_monitor_service` - (Optional) Disable enhance service for monitor, it is enabled by default. When this options is set, monitor agent won't be installed.
8890
* `disable_security_service` - (Optional) Disable enhance service for security, it is enabled by default. When this options is set, security agent won't be installed.

0 commit comments

Comments
 (0)