From fc126e05f167a87c5834827ef7aa1152d784e482 Mon Sep 17 00:00:00 2001 From: hellertang Date: Mon, 29 Apr 2024 15:53:41 +0800 Subject: [PATCH 1/2] add cvm output --- .../services/cvm/data_source_tc_instances.go | 6 ++++++ .../services/cvm/resource_tc_instance.go | 18 ++++++++++++++++++ website/docs/d/instances.html.markdown | 1 + website/docs/r/instance.html.markdown | 3 +++ 4 files changed, 28 insertions(+) diff --git a/tencentcloud/services/cvm/data_source_tc_instances.go b/tencentcloud/services/cvm/data_source_tc_instances.go index 5b201f12a6..fb0a158882 100644 --- a/tencentcloud/services/cvm/data_source_tc_instances.go +++ b/tencentcloud/services/cvm/data_source_tc_instances.go @@ -103,6 +103,11 @@ func DataSourceTencentCloudInstances() *schema.Resource { Computed: true, Description: "Instance memory capacity, unit in GB.", }, + "os_name": { + Type: schema.TypeString, + Computed: true, + Description: "Instance os name.", + }, "availability_zone": { Type: schema.TypeString, Computed: true, @@ -306,6 +311,7 @@ func dataSourceTencentCloudInstancesRead(d *schema.ResourceData, meta interface{ "instance_type": instance.InstanceType, "cpu": instance.CPU, "memory": instance.Memory, + "os_name": instance.OsName, "availability_zone": instance.Placement.Zone, "project_id": instance.Placement.ProjectId, "image_id": instance.ImageId, diff --git a/tencentcloud/services/cvm/resource_tc_instance.go b/tencentcloud/services/cvm/resource_tc_instance.go index 67b1e2ebaa..7dc925baef 100644 --- a/tencentcloud/services/cvm/resource_tc_instance.go +++ b/tencentcloud/services/cvm/resource_tc_instance.go @@ -409,6 +409,21 @@ func ResourceTencentCloudInstance() *schema.Resource { Computed: true, Description: "Expired time of the instance.", }, + "cpu": { + Type: schema.TypeInt, + Computed: true, + Description: "The number of CPU cores of the instance.", + }, + "memory": { + Type: schema.TypeInt, + Computed: true, + Description: "Instance memory capacity, unit in GB.", + }, + "os_name": { + Type: schema.TypeString, + Computed: true, + Description: "Instance os name.", + }, }, } } @@ -829,6 +844,9 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{}) _ = d.Set("expired_time", instance.ExpiredTime) _ = d.Set("cam_role_name", instance.CamRoleName) _ = d.Set("disable_api_termination", instance.DisableApiTermination) + _ = d.Set("cpu", instance.CPU) + _ = d.Set("memory", instance.Memory) + _ = d.Set("os_name", instance.OsName) if instance.Uuid != nil { _ = d.Set("uuid", instance.Uuid) diff --git a/website/docs/d/instances.html.markdown b/website/docs/d/instances.html.markdown index abad8d0c64..862799b274 100644 --- a/website/docs/d/instances.html.markdown +++ b/website/docs/d/instances.html.markdown @@ -58,6 +58,7 @@ In addition to all arguments above, the following attributes are exported: * `internet_charge_type` - The charge type of the instance. * `internet_max_bandwidth_out` - Public network maximum output bandwidth of the instance. * `memory` - Instance memory capacity, unit in GB. + * `os_name` - Instance os name. * `private_ip` - Private IP of the instance. * `project_id` - The project CVM belongs to. * `public_ip` - Public IP of the instance. diff --git a/website/docs/r/instance.html.markdown b/website/docs/r/instance.html.markdown index 8ab3514f74..21a3e4907e 100644 --- a/website/docs/r/instance.html.markdown +++ b/website/docs/r/instance.html.markdown @@ -165,9 +165,12 @@ The `data_disks` object supports the following: In addition to all arguments above, the following attributes are exported: * `id` - ID of the resource. +* `cpu` - The number of CPU cores of the instance. * `create_time` - Create time of the instance. * `expired_time` - Expired time of the instance. * `instance_status` - Current status of the instance. +* `memory` - Instance memory capacity, unit in GB. +* `os_name` - Instance os name. * `public_ip` - Public IP of the instance. * `uuid` - Globally unique ID of the instance. From b8016e51f9d3ed74c8133f43c29b30387cb19cc2 Mon Sep 17 00:00:00 2001 From: hellertang Date: Mon, 29 Apr 2024 15:58:12 +0800 Subject: [PATCH 2/2] add cvm output --- .changelog/2608.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changelog/2608.txt diff --git a/.changelog/2608.txt b/.changelog/2608.txt new file mode 100644 index 0000000000..6e53dc8084 --- /dev/null +++ b/.changelog/2608.txt @@ -0,0 +1,7 @@ +```release-note:enhancement +resource/tencentcloud_instance: add output `memory`, `os_name`, `cpu` +``` + +```release-note:enhancement +datasource/tencentcloud_instances: add output `os_name` +``` \ No newline at end of file