Skip to content

Commit 4269573

Browse files
authored
Merge pull request #597 from ChrisdeR/feature/cvm_cam_role
modify resource tencentcloud_tcr_instance and resource tencentcloud_instance
2 parents 6819428 + 356ca7a commit 4269573

File tree

6 files changed

+28
-1
lines changed

6 files changed

+28
-1
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
## 1.53.8 (Unreleased)
22

3+
ENHANCEMENTS:
4+
5+
* Resource `tencentcloud_instance` add `cam_role_name` to support binding role to cvm instance.
6+
37
BUG FIXES:
48

59
* 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.
611

712
## 1.53.7 (March 10, 2021)
813

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/resource_tc_instance.go

Lines changed: 12 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"
@@ -384,6 +385,13 @@ func resourceTencentCloudInstance() *schema.Resource {
384385
Default: false,
385386
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.",
386387
},
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+
},
387395
// Computed values.
388396
"instance_status": {
389397
Type: schema.TypeString,
@@ -435,6 +443,9 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
435443
if v, ok := d.GetOk("hostname"); ok {
436444
request.HostName = helper.String(v.(string))
437445
}
446+
if v, ok := d.GetOk("cam_role_name"); ok {
447+
request.CamRoleName = helper.String(v.(string))
448+
}
438449

439450
if v, ok := d.GetOk("instance_charge_type"); ok {
440451
instanceChargeType := v.(string)
@@ -780,6 +791,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
780791
_ = d.Set("instance_status", instance.InstanceState)
781792
_ = d.Set("create_time", instance.CreatedTime)
782793
_ = d.Set("expired_time", instance.ExpiredTime)
794+
_ = d.Set("cam_role_name", instance.CamRoleName)
783795

784796
if _, ok := d.GetOkExists("allocate_public_ip"); !ok {
785797
_ = 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)