Skip to content

fix(cvm): [123481747]support hpc_cluster_id #3312

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 3 commits into from
Apr 16, 2025
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
3 changes: 3 additions & 0 deletions .changelog/3312.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/tencentcloud_instance: support hpc_cluster_id
```
12 changes: 12 additions & 0 deletions tencentcloud/services/cvm/resource_tc_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,13 @@ func ResourceTencentCloudInstance() *schema.Resource {
Optional: true,
Description: "CAM role name authorized to access.",
},
"hpc_cluster_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Description: "High-performance computing cluster ID. If the instance created is a high-performance computing instance, you need to specify the cluster in which the instance is placed, otherwise it cannot be specified.",
},
// Computed values.
"instance_status": {
Type: schema.TypeString,
Expand Down Expand Up @@ -509,6 +516,10 @@ func resourceTencentCloudInstanceCreate(d *schema.ResourceData, meta interface{}
request.CamRoleName = helper.String(v.(string))
}

if v, ok := d.GetOk("hpc_cluster_id"); ok {
request.HpcClusterId = helper.String(v.(string))
}

if v, ok := d.GetOk("instance_charge_type"); ok {
instanceChargeType := v.(string)
request.InstanceChargeType = &instanceChargeType
Expand Down Expand Up @@ -959,6 +970,7 @@ func resourceTencentCloudInstanceRead(d *schema.ResourceData, meta interface{})
_ = d.Set("cpu", instance.CPU)
_ = d.Set("memory", instance.Memory)
_ = d.Set("os_name", instance.OsName)
_ = d.Set("hpc_cluster_id", instance.HpcClusterId)

if instance.Uuid != nil {
_ = d.Set("uuid", instance.Uuid)
Expand Down
64 changes: 64 additions & 0 deletions tencentcloud/services/cvm/resource_tc_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2931,3 +2931,67 @@ resource "tencentcloud_instance" "cvm_with_orderly_sg" {
orderly_security_groups = ["sg-cm7fbbf3", "sg-kensue7b", "sg-05f7wnhn"]
}
`

func TestAccTencentCloudInstanceResourceHPC(t *testing.T) {
t.Parallel()
resource.Test(t, resource.TestCase{
PreCheck: func() {
acctest.AccPreCheck(t)
},
Providers: acctest.AccProviders,
CheckDestroy: testAccCheckCvmInstanceDestroy,
Steps: []resource.TestStep{
{
Config: testAccTencentCloudInstanceHPC,
Check: resource.ComposeTestCheckFunc(
testAccCheckCvmInstanceExists("tencentcloud_instance.hpc"),
resource.TestCheckResourceAttr("tencentcloud_instance.hpc", "instance_status", "RUNNING"),
resource.TestCheckResourceAttrSet("tencentcloud_instance.hpc", "hpc_cluster_id"),
),
},
},
})
}

const testAccTencentCloudInstanceHPC = `
locals {
availability_zone = "ap-shanghai-5"
instance_type = "HCCS5.24XLARGE384"
}

resource "tencentcloud_cvm_hpc_cluster" "hpc_cluster" {
zone = local.availability_zone
name = "terraform-test"
remark = "create for test"
}

data "tencentcloud_images" "default" {
instance_type = local.instance_type
}

resource "tencentcloud_vpc" "vpc" {
cidr_block = "10.0.0.0/16"
name = "vpc"
}

resource "tencentcloud_subnet" "subnet" {
vpc_id = tencentcloud_vpc.vpc.id
availability_zone = local.availability_zone
name = "subnet"
cidr_block = "10.0.1.0/24"
}

resource "tencentcloud_instance" "hpc" {
instance_name = "tf-example"
availability_zone = local.availability_zone
image_id = data.tencentcloud_images.default.images.0.image_id
instance_type = local.instance_type
system_disk_type = "LOCAL_BASIC"
system_disk_size = 440
hostname = "user"
project_id = 0
vpc_id = tencentcloud_vpc.vpc.id
subnet_id = tencentcloud_subnet.subnet.id
hpc_cluster_id = tencentcloud_cvm_hpc_cluster.hpc_cluster.id
}
`
1 change: 1 addition & 0 deletions website/docs/r/instance.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ The following arguments are supported:
* `disable_security_service` - (Optional, Bool) Disable enhance service for security, it is enabled by default. When this options is set, security agent won't be installed. Modifications may lead to the reinstallation of the instance's operating system.
* `force_delete` - (Optional, Bool) 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.
* `hostname` - (Optional, String) The hostname of the instance. Windows instance: The name should be a combination of 2 to 15 characters comprised of letters (case insensitive), numbers, and hyphens (-). Period (.) is not supported, and the name cannot be a string of pure numbers. Other types (such as Linux) of instances: The name should be a combination of 2 to 60 characters, supporting multiple periods (.). The piece between two periods is composed of letters (case insensitive), numbers, and hyphens (-). Modifications may lead to the reinstallation of the instance's operating system.
* `hpc_cluster_id` - (Optional, String, ForceNew) High-performance computing cluster ID. If the instance created is a high-performance computing instance, you need to specify the cluster in which the instance is placed, otherwise it cannot be specified.
* `instance_charge_type_prepaid_period` - (Optional, Int) The tenancy (time unit is month) of the prepaid instance, NOTE: it only works when instance_charge_type is set to `PREPAID`. Valid values are `1`, `2`, `3`, `4`, `5`, `6`, `7`, `8`, `9`, `10`, `11`, `12`, `24`, `36`, `48`, `60`.
* `instance_charge_type_prepaid_renew_flag` - (Optional, String) Auto renewal flag. Valid values: `NOTIFY_AND_AUTO_RENEW`: notify upon expiration and renew automatically, `NOTIFY_AND_MANUAL_RENEW`: notify upon expiration but do not renew automatically, `DISABLE_NOTIFY_AND_MANUAL_RENEW`: neither notify upon expiration nor renew automatically. Default value: `NOTIFY_AND_MANUAL_RENEW`. If this parameter is specified as `NOTIFY_AND_AUTO_RENEW`, the instance will be automatically renewed on a monthly basis if the account balance is sufficient. NOTE: it only works when instance_charge_type is set to `PREPAID`.
* `instance_charge_type` - (Optional, String) The charge type of instance. Valid values are `PREPAID`, `POSTPAID_BY_HOUR`, `SPOTPAID`, `CDHPAID` and `CDCPAID`. The default is `POSTPAID_BY_HOUR`. Note: TencentCloud International only supports `POSTPAID_BY_HOUR` and `CDHPAID`. `PREPAID` instance may not allow to delete before expired. `SPOTPAID` instance must set `spot_instance_type` and `spot_max_price` at the same time. `CDHPAID` instance must set `cdh_instance_type` and `cdh_host_id`.
Expand Down
Loading