diff --git a/.changelog/3254.txt b/.changelog/3254.txt new file mode 100644 index 0000000000..7b24d450d0 --- /dev/null +++ b/.changelog/3254.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_cvm_launch_template: fix some problems +``` \ No newline at end of file diff --git a/tencentcloud/services/cvm/resource_tc_cvm_launch_template.go b/tencentcloud/services/cvm/resource_tc_cvm_launch_template.go index ea48b016fe..e0da04e915 100644 --- a/tencentcloud/services/cvm/resource_tc_cvm_launch_template.go +++ b/tencentcloud/services/cvm/resource_tc_cvm_launch_template.go @@ -99,7 +99,7 @@ func ResourceTencentCloudCvmLaunchTemplate() *schema.Resource { }, "disk_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "System disk ID.", }, "disk_size": { @@ -135,7 +135,7 @@ func ResourceTencentCloudCvmLaunchTemplate() *schema.Resource { }, "disk_id": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Data disk ID.", }, "delete_with_instance": { @@ -665,9 +665,6 @@ func resourceTencentCloudCvmLaunchTemplateCreate(d *schema.ResourceData, meta in 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)) } @@ -687,9 +684,6 @@ func resourceTencentCloudCvmLaunchTemplateCreate(d *schema.ResourceData, meta in 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)) } @@ -763,8 +757,8 @@ func resourceTencentCloudCvmLaunchTemplateCreate(d *schema.ResourceData, meta in 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() @@ -773,8 +767,8 @@ func resourceTencentCloudCvmLaunchTemplateCreate(d *schema.ResourceData, meta in 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.html.markdown b/website/docs/r/cvm_launch_template.html.markdown index 2c2cf8c501..53c9644e09 100644 --- a/website/docs/r/cvm_launch_template.html.markdown +++ b/website/docs/r/cvm_launch_template.html.markdown @@ -77,7 +77,6 @@ The `data_disks` object supports the following: * `disk_size` - (Required, Int) The size of the data disk. * `cdc_id` - (Optional, String) Cloud Dedicated Cluster(CDC) ID. * `delete_with_instance` - (Optional, Bool) Whether the data disk is destroyed along with the instance, true or false. -* `disk_id` - (Optional, String) Data disk ID. * `disk_type` - (Optional, String) The type of data disk. * `encrypt` - (Optional, Bool) Whether the data disk is encrypted, TRUE or FALSE. * `kms_key_id` - (Optional, String) The id of custom CMK. @@ -148,7 +147,6 @@ The `storage_block_attr` object of `externals` supports the following: The `system_disk` object supports the following: * `cdc_id` - (Optional, String) Cloud Dedicated Cluster(CDC) ID. -* `disk_id` - (Optional, String) System disk ID. * `disk_size` - (Optional, Int) The size of system disk. * `disk_type` - (Optional, String) The type of system disk.