@@ -464,6 +464,38 @@ func TestAccTencentCloudInstanceWithSpotpaid(t *testing.T) {
464464 })
465465}
466466
467+ func TestAccTencentCloudInstancePostpaidToPrepaid (t * testing.T ) {
468+ t .Parallel ()
469+
470+ id := "tencentcloud_instance.foo"
471+ resource .Test (t , resource.TestCase {
472+ PreCheck : func () { testAccPreCheckCommon (t , ACCOUNT_TYPE_PREPAY ) },
473+ IDRefreshName : id ,
474+ Providers : testAccProviders ,
475+ CheckDestroy : testAccCheckInstanceDestroy ,
476+ Steps : []resource.TestStep {
477+ {
478+ Config : testAccTencentCloudInstancePostPaid ,
479+ Check : resource .ComposeTestCheckFunc (
480+ testAccCheckTencentCloudDataSourceID (id ),
481+ testAccCheckTencentCloudInstanceExists (id ),
482+ resource .TestCheckResourceAttr (id , "instance_status" , "RUNNING" ),
483+ ),
484+ },
485+ {
486+ Config : testAccTencentCloudInstanceBasicToPrepaid ,
487+ Check : resource .ComposeTestCheckFunc (
488+ testAccCheckTencentCloudDataSourceID (id ),
489+ testAccCheckTencentCloudInstanceExists (id ),
490+ resource .TestCheckResourceAttr (id , "instance_charge_type" , "PREPAID" ),
491+ resource .TestCheckResourceAttr (id , "instance_charge_type_prepaid_period" , "1" ),
492+ resource .TestCheckResourceAttr (id , "instance_charge_type_prepaid_renew_flag" , "NOTIFY_AND_MANUAL_RENEW" ),
493+ ),
494+ },
495+ },
496+ })
497+ }
498+
467499func testAccCheckTencentCloudInstanceExists (n string ) resource.TestCheckFunc {
468500 return func (s * terraform.State ) error {
469501 logId := getLogId (contextNil )
@@ -524,7 +556,7 @@ func testAccCheckInstanceDestroy(s *terraform.State) error {
524556 if err != nil {
525557 return err
526558 }
527- if instance != nil {
559+ if instance != nil && * instance . InstanceState != CVM_STATUS_SHUTDOWN && * instance . InstanceState != CVM_STATUS_TERMINATING {
528560 return fmt .Errorf ("cvm instance still exists: %s" , rs .Primary .ID )
529561 }
530562 }
@@ -544,6 +576,49 @@ resource "tencentcloud_instance" "foo" {
544576}
545577`
546578
579+ const testAccTencentCloudInstancePostPaid = `
580+ data "tencentcloud_instance_types" "default" {
581+ filter {
582+ name = "instance-family"
583+ values = ["S1"]
584+ }
585+
586+ cpu_core_count = 1
587+ memory_size = 1
588+ }
589+
590+ resource "tencentcloud_instance" "foo" {
591+ instance_name = "` + defaultInsName + `"
592+ availability_zone = "` + defaultAZone + `"
593+ image_id = "` + defaultTkeOSImageId + `"
594+ instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
595+ system_disk_type = "CLOUD_PREMIUM"
596+ }
597+ `
598+
599+ const testAccTencentCloudInstanceBasicToPrepaid = `
600+ data "tencentcloud_instance_types" "default" {
601+ filter {
602+ name = "instance-family"
603+ values = ["S1"]
604+ }
605+
606+ cpu_core_count = 1
607+ memory_size = 1
608+ }
609+
610+ resource "tencentcloud_instance" "foo" {
611+ instance_name = "` + defaultInsName + `"
612+ availability_zone = "` + defaultAZone + `"
613+ image_id = "` + defaultTkeOSImageId + `"
614+ instance_type = data.tencentcloud_instance_types.default.instance_types.0.instance_type
615+ system_disk_type = "CLOUD_PREMIUM"
616+ instance_charge_type = "PREPAID"
617+ instance_charge_type_prepaid_period = 1
618+ instance_charge_type_prepaid_renew_flag = "NOTIFY_AND_MANUAL_RENEW"
619+ }
620+ `
621+
547622const testAccTencentCloudInstanceModifyInstanceType = defaultInstanceVariable + `
548623data "tencentcloud_instance_types" "new_type" {
549624 filter {
0 commit comments