Skip to content

Commit 8aea9bc

Browse files
committed
fix bug about setting tags in resource tencentcloud_tcr_instance and add cam_role_name to resource tencentcloud_instance
1 parent f4c1540 commit 8aea9bc

File tree

4 files changed

+24
-1
lines changed

4 files changed

+24
-1
lines changed

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
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_tcr_instance` fix bug that only one tag is effective when setting multiple tags.
10+
211
## 1.53.7 (March 10, 2021)
312

413
ENHANCEMENTS:

tencentcloud/resource_tc_instance.go

Lines changed: 11 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"
@@ -383,6 +384,13 @@ func resourceTencentCloudInstance() *schema.Resource {
383384
Default: false,
384385
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.",
385386
},
387+
// role
388+
"cam_role_name": {
389+
Type: schema.TypeString,
390+
ForceNew: true,
391+
Optional: true,
392+
Description: "CAM role name authorized to access.",
393+
},
386394
// Computed values.
387395
"instance_status": {
388396
Type: schema.TypeString,
@@ -434,6 +442,9 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
434442
if v, ok := d.GetOk("hostname"); ok {
435443
request.HostName = helper.String(v.(string))
436444
}
445+
if v, ok := d.GetOk("cam_role_name"); ok {
446+
request.CamRoleName = helper.String(v.(string))
447+
}
437448

438449
if v, ok := d.GetOk("instance_charge_type"); ok {
439450
instanceChargeType := v.(string)

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/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)