Skip to content

Commit e8de5db

Browse files
committed
add
1 parent 4693e92 commit e8de5db

File tree

4 files changed

+53
-8
lines changed

4 files changed

+53
-8
lines changed

.changelog/2719.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```release-note:enhancement
2+
resource/tencentcloud_instance: add params `dedicated_cluster_id`
3+
```
4+
5+
```release-note:enhancement
6+
data_source/tencentcloud_instances: add params `dedicated_cluster_id`
7+
```
8+
9+
```release-note:enhancement
10+
resource/tencentcloud_cvm_launch_template: deprecated `host_ips` param
11+
```
12+
13+
```release-note:enhancement
14+
data_source/tencentcloud_cvm_chc_hosts: deprecated `host_ips` param
15+
```

tencentcloud/services/cvm/data_source_tc_instances.go

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ func DataSourceTencentCloudInstances() *schema.Resource {
5050
Optional: true,
5151
Description: "ID of a vpc subnetwork.",
5252
},
53+
"dedicated_cluster_id": {
54+
Type: schema.TypeString,
55+
Optional: true,
56+
Description: "Exclusive cluster id.",
57+
},
5358
"instance_set_ids": {
5459
Type: schema.TypeList,
5560
Optional: true,
@@ -93,6 +98,11 @@ func DataSourceTencentCloudInstances() *schema.Resource {
9398
Computed: true,
9499
Description: "Type of the instance.",
95100
},
101+
"dedicated_cluster_id": {
102+
Type: schema.TypeString,
103+
Computed: true,
104+
Description: "Exclusive cluster id.",
105+
},
96106
"cpu": {
97107
Type: schema.TypeInt,
98108
Computed: true,
@@ -252,33 +262,43 @@ func DataSourceTencentCloudInstances() *schema.Resource {
252262

253263
func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{}) error {
254264
defer tccommon.LogElapsed("data_source.tencentcloud_instances.read")()
255-
logId := tccommon.GetLogId(tccommon.ContextNil)
256-
ctx := context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
257-
cvmService := CvmService{
258-
client: meta.(tccommon.ProviderMeta).GetAPIV3Conn(),
259-
}
260265

261-
var instanceSetIds []*string
266+
var (
267+
logId = tccommon.GetLogId(tccommon.ContextNil)
268+
ctx = context.WithValue(context.TODO(), tccommon.LogIdKey, logId)
269+
cvmService = CvmService{client: meta.(tccommon.ProviderMeta).GetAPIV3Conn()}
270+
instanceSetIds []*string
271+
)
262272

263273
filter := make(map[string]string)
264274
if v, ok := d.GetOk("instance_id"); ok {
265275
filter["instance-id"] = v.(string)
266276
}
277+
267278
if v, ok := d.GetOk("instance_name"); ok {
268279
filter["instance-name"] = v.(string)
269280
}
281+
270282
if v, ok := d.GetOk("availability_zone"); ok {
271283
filter["zone"] = v.(string)
272284
}
285+
273286
if v, ok := d.GetOkExists("project_id"); ok {
274287
filter["project-id"] = fmt.Sprintf("%d", v.(int))
275288
}
289+
276290
if v, ok := d.GetOk("vpc_id"); ok {
277291
filter["vpc-id"] = v.(string)
278292
}
293+
279294
if v, ok := d.GetOk("subnet_id"); ok {
280295
filter["subnet-id"] = v.(string)
281296
}
297+
298+
if v, ok := d.GetOk("dedicated_cluster_id"); ok {
299+
filter["dedicated-cluster-id"] = v.(string)
300+
}
301+
282302
if v, ok := d.GetOk("instance_set_ids"); ok {
283303
instanceSetIds = helper.InterfacesStringsPoint(v.([]interface{}))
284304
}
@@ -296,8 +316,10 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
296316
if errRet != nil {
297317
return tccommon.RetryError(errRet, tccommon.InternalError)
298318
}
319+
299320
return nil
300321
})
322+
301323
if err != nil {
302324
return err
303325
}
@@ -309,6 +331,7 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
309331
"instance_id": instance.InstanceId,
310332
"instance_name": instance.InstanceName,
311333
"instance_type": instance.InstanceType,
334+
"dedicated_cluster_id": instance.DedicatedClusterId,
312335
"cpu": instance.CPU,
313336
"memory": instance.Memory,
314337
"os_name": instance.OsName,
@@ -332,12 +355,15 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
332355
"instance_charge_type_prepaid_renew_flag": instance.RenewFlag,
333356
"cam_role_name": instance.CamRoleName,
334357
}
358+
335359
if len(instance.PublicIpAddresses) > 0 {
336360
mapping["public_ip"] = *instance.PublicIpAddresses[0]
337361
}
362+
338363
if len(instance.PrivateIpAddresses) > 0 {
339364
mapping["private_ip"] = *instance.PrivateIpAddresses[0]
340365
}
366+
341367
dataDisks := make([]map[string]interface{}, 0, len(instance.DataDisks))
342368
for _, v := range instance.DataDisks {
343369
dataDisk := map[string]interface{}{
@@ -346,8 +372,10 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
346372
"data_disk_id": v.DiskId,
347373
"delete_with_instance": v.DeleteWithInstance,
348374
}
375+
349376
dataDisks = append(dataDisks, dataDisk)
350377
}
378+
351379
mapping["data_disks"] = dataDisks
352380
instanceList = append(instanceList, mapping)
353381
ids = append(ids, *instance.InstanceId)
@@ -366,6 +394,6 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{
366394
return err
367395
}
368396
}
369-
return nil
370397

398+
return nil
371399
}

tencentcloud/services/cvm/resource_tc_instance.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
889889
}
890890

891891
_ = d.Set("availability_zone", instance.Placement.Zone)
892-
//_ = d.Set("dedicated_cluster_id", instance.DedicatedClusterId)
892+
_ = d.Set("dedicated_cluster_id", instance.DedicatedClusterId)
893893
_ = d.Set("instance_name", instance.InstanceName)
894894
_ = d.Set("instance_type", instance.InstanceType)
895895
_ = d.Set("project_id", instance.Placement.ProjectId)

website/docs/d/instances.html.markdown

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ data "tencentcloud_instances" "example" {
4949
The following arguments are supported:
5050

5151
* `availability_zone` - (Optional, String) The available zone that the CVM instance locates at.
52+
* `dedicated_cluster_id` - (Optional, String) Exclusive cluster id.
5253
* `instance_id` - (Optional, String) ID of the instances to be queried.
5354
* `instance_name` - (Optional, String) Name of the instances to be queried.
5455
* `instance_set_ids` - (Optional, List: [`String`]) Instance set ids, max length is 100, conflict with other field.
@@ -73,6 +74,7 @@ In addition to all arguments above, the following attributes are exported:
7374
* `data_disk_size` - Size of the data disk.
7475
* `data_disk_type` - Type of the data disk.
7576
* `delete_with_instance` - Indicates whether the data disk is destroyed with the instance.
77+
* `dedicated_cluster_id` - Exclusive cluster id.
7678
* `expired_time` - Expired time of the instance.
7779
* `image_id` - ID of the image.
7880
* `instance_charge_type_prepaid_renew_flag` - The way that CVM instance will be renew automatically or not when it reach the end of the prepaid tenancy.

0 commit comments

Comments
 (0)