diff --git a/.changelog/3250.txt b/.changelog/3250.txt new file mode 100644 index 0000000000..44002812d4 --- /dev/null +++ b/.changelog/3250.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_cvm_launch_template_version: fix some problems +``` \ No newline at end of file diff --git a/tencentcloud/services/cvm/resource_tc_cvm_launch_template_version.go b/tencentcloud/services/cvm/resource_tc_cvm_launch_template_version.go index deda40a6f3..bd447a9ae9 100644 --- a/tencentcloud/services/cvm/resource_tc_cvm_launch_template_version.go +++ b/tencentcloud/services/cvm/resource_tc_cvm_launch_template_version.go @@ -127,7 +127,6 @@ func ResourceTencentCloudCvmLaunchTemplateVersion() *schema.Resource { }, "disk_id": { Type: schema.TypeString, - Optional: true, Computed: true, ForceNew: true, Description: "System disk ID. System disks whose type is LOCAL_BASIC or LOCAL_SSD do not have an ID and do not support this parameter. It is only used as a response parameter for APIs such as DescribeInstances, and cannot be used as a request parameter for APIs such as RunInstances.", @@ -173,7 +172,6 @@ func ResourceTencentCloudCvmLaunchTemplateVersion() *schema.Resource { }, "disk_id": { Type: schema.TypeString, - Optional: true, Computed: true, ForceNew: true, Description: "System disk ID. System disks whose type is LOCAL_BASIC or LOCAL_SSD do not have an ID and do not support this parameter. It is only used as a response parameter for APIs such as DescribeInstances, and cannot be used as a request parameter for APIs such as RunInstances.", @@ -469,7 +467,7 @@ func ResourceTencentCloudCvmLaunchTemplateVersion() *schema.Resource { ForceNew: true, Type: schema.TypeList, MaxItems: 1, - Description: "Scheduled tasks.", + Description: "Scheduled tasks. You can use this parameter to specify scheduled tasks for the instance. Only scheduled termination is supported.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "timer_action": { @@ -781,9 +779,6 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData, if v, ok := dMap["disk_type"]; ok { systemDisk.DiskType = helper.String(v.(string)) } - if v, ok := dMap["disk_id"]; ok { - systemDisk.DiskId = helper.String(v.(string)) - } if v, ok := dMap["disk_size"]; ok { systemDisk.DiskSize = helper.IntInt64(v.(int)) } @@ -803,9 +798,6 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData, if v, ok := dMap["disk_type"]; ok { dataDisk.DiskType = helper.String(v.(string)) } - if v, ok := dMap["disk_id"]; ok { - dataDisk.DiskId = helper.String(v.(string)) - } if v, ok := dMap["delete_with_instance"]; ok { dataDisk.DeleteWithInstance = helper.Bool(v.(bool)) } @@ -854,8 +846,8 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData, if dMap, ok := helper.InterfacesHeadMap(d, "internet_accessible"); ok { internetAccessible := cvm.InternetAccessible{} - if v, ok := dMap["internet_charge_type"]; ok { - internetAccessible.InternetChargeType = helper.String(v.(string)) + if v, ok := dMap["internet_charge_type"].(string); ok && v != "" { + internetAccessible.InternetChargeType = helper.String(v) } if v, ok := dMap["internet_max_bandwidth_out"]; ok { internetAccessible.InternetMaxBandwidthOut = helper.IntInt64(v.(int)) @@ -863,8 +855,8 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData, if v, ok := dMap["public_ip_assigned"]; ok { internetAccessible.PublicIpAssigned = helper.Bool(v.(bool)) } - if v, ok := dMap["bandwidth_package_id"]; ok { - internetAccessible.BandwidthPackageId = helper.String(v.(string)) + if v, ok := dMap["bandwidth_package_id"].(string); ok && v != "" { + internetAccessible.BandwidthPackageId = helper.String(v) } request.InternetAccessible = &internetAccessible } @@ -879,8 +871,8 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData, if dMap, ok := helper.InterfacesHeadMap(d, "login_settings"); ok { loginSettings := cvm.LoginSettings{} - if v, ok := dMap["password"]; ok { - loginSettings.Password = helper.String(v.(string)) + if v, ok := dMap["password"].(string); ok && v != "" { + loginSettings.Password = helper.String(v) } if v, ok := dMap["key_ids"]; ok { keyIdsSet := v.(*schema.Set).List() @@ -889,8 +881,8 @@ func resourceTencentCloudCvmLaunchTemplateVersionCreate(d *schema.ResourceData, loginSettings.KeyIds = append(loginSettings.KeyIds, &keyIds) } } - if v, ok := dMap["keep_image_login"]; ok { - loginSettings.KeepImageLogin = helper.String(v.(string)) + if v, ok := dMap["keep_image_login"].(string); ok && v != "" { + loginSettings.KeepImageLogin = helper.String(v) } request.LoginSettings = &loginSettings } diff --git a/website/docs/r/cvm_launch_template_version.html.markdown b/website/docs/r/cvm_launch_template_version.html.markdown index a7f1629ee2..82978449ed 100644 --- a/website/docs/r/cvm_launch_template_version.html.markdown +++ b/website/docs/r/cvm_launch_template_version.html.markdown @@ -34,7 +34,7 @@ The following arguments are supported: * `launch_template_id` - (Required, String, ForceNew) Instance launch template ID. This parameter is used as a basis for creating new template versions. * `placement` - (Required, List, ForceNew) Location of the instance. You can use this parameter to specify the attributes of the instance, such as its availability zone, project, and CDH (for dedicated CVMs). -* `action_timer` - (Optional, List, ForceNew) Scheduled tasks. +* `action_timer` - (Optional, List, ForceNew) Scheduled tasks. You can use this parameter to specify scheduled tasks for the instance. Only scheduled termination is supported. * `cam_role_name` - (Optional, String, ForceNew) The role name of CAM. * `client_token` - (Optional, String, ForceNew) A unique string supplied by the client to ensure that the request is idempotent. Its maximum length is 64 ASCII characters. If this parameter is not specified, the idem-potency of the request cannot be guaranteed. * `data_disks` - (Optional, List, ForceNew) The configuration information of instance data disks. If this parameter is not specified, no data disk will be purchased by default. @@ -76,7 +76,6 @@ The `data_disks` object supports the following: * `disk_size` - (Required, Int, ForceNew) Data disk size (in GB). The minimum adjustment increment is 10 GB. The value range varies by data disk type. * `cdc_id` - (Optional, String, ForceNew) ID of the dedicated cluster to which the instance belongs. * `delete_with_instance` - (Optional, Bool, ForceNew) Whether to terminate the data disk when its CVM is terminated. Default value: `true`. -* `disk_id` - (Optional, String, ForceNew) System disk ID. System disks whose type is LOCAL_BASIC or LOCAL_SSD do not have an ID and do not support this parameter. It is only used as a response parameter for APIs such as DescribeInstances, and cannot be used as a request parameter for APIs such as RunInstances. * `disk_type` - (Optional, String, ForceNew) The type of data disk. * `encrypt` - (Optional, Bool, ForceNew) Specifies whether the data disk is encrypted. * `kms_key_id` - (Optional, String, ForceNew) ID of the custom CMK in the format of UUID or `kms-abcd1234`. @@ -147,7 +146,6 @@ The `storage_block_attr` object of `externals` supports the following: The `system_disk` object supports the following: * `cdc_id` - (Optional, String, ForceNew) ID of the dedicated cluster to which the instance belongs. -* `disk_id` - (Optional, String, ForceNew) System disk ID. System disks whose type is LOCAL_BASIC or LOCAL_SSD do not have an ID and do not support this parameter. It is only used as a response parameter for APIs such as DescribeInstances, and cannot be used as a request parameter for APIs such as RunInstances. * `disk_size` - (Optional, Int, ForceNew) System disk size; unit: GB; default value: 50 GB. * `disk_type` - (Optional, String, ForceNew) The type of system disk. Default value: the type of hard disk currently in stock.