Skip to content

feat(cvm): [117096263] Output cpu, memory, os_name #2608

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changelog/2608.txt
Original file line number Diff line number Diff line change
@@ -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`
```
6 changes: 6 additions & 0 deletions tencentcloud/services/cvm/data_source_tc_instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
18 changes: 18 additions & 0 deletions tencentcloud/services/cvm/resource_tc_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,21 @@ func ResourceTencentCloudInstance() *schema.Resource {
Computed: true,
Description: "Expired time of the instance.",
},
"cpu": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

新加的几个字段我们是不是需要完善下测试用例

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.",
},
},
}
}
Expand Down Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions website/docs/d/instances.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions website/docs/r/instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
Loading