@@ -234,6 +234,44 @@ func TestAccTencentCloudPostgresqlInstanceResource_prepaid(t *testing.T) {
234234 })
235235}
236236
237+ func TestAccTencentCloudPostgresqlInstanceResource_postpaid_to_prepaid (t * testing.T ) {
238+ resource .Test (t , resource.TestCase {
239+ PreCheck : func () { testAccPreCheckCommon (t , ACCOUNT_TYPE_PREPAY ) },
240+ Providers : testAccProviders ,
241+ CheckDestroy : testAccCheckPostgresqlInstanceDestroy ,
242+ Steps : []resource.TestStep {
243+ {
244+ PreConfig : func () { testAccStepPreConfigSetTempAKSK (t , ACCOUNT_TYPE_PREPAY ) },
245+ Config : testAccPostgresqlInstancePostpaid ,
246+ Check : resource .ComposeTestCheckFunc (
247+ testAccCheckPostgresqlInstanceExists (testPostgresqlInstanceResourceKey ),
248+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "id" ),
249+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "name" , "tf_postsql_postpaid" ),
250+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "charge_type" , "POSTPAID_BY_HOUR" ),
251+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "period" ),
252+ ),
253+ },
254+ {
255+ PreConfig : func () { testAccStepPreConfigSetTempAKSK (t , ACCOUNT_TYPE_PREPAY ) },
256+ Config : testAccPostgresqlInstancePostpaid_to_Prepaid ,
257+ Check : resource .ComposeTestCheckFunc (
258+ testAccCheckPostgresqlInstanceExists (testPostgresqlInstanceResourceKey ),
259+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "id" ),
260+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "name" , "tf_postsql_postpaid_updated_to_prepaid" ),
261+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "charge_type" , "PREPAID" ),
262+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "period" , "2" ),
263+ ),
264+ },
265+ {
266+ ResourceName : testPostgresqlInstanceResourceKey ,
267+ ImportState : true ,
268+ ImportStateVerify : true ,
269+ ImportStateVerifyIgnore : []string {"root_password" , "spec_code" , "public_access_switch" , "charset" , "backup_plan" , "period" },
270+ },
271+ },
272+ })
273+ }
274+
237275func TestAccTencentCloudPostgresqlInstanceResource_MAZ (t * testing.T ) {
238276 t .Parallel ()
239277 resource .Test (t , resource.TestCase {
@@ -363,6 +401,63 @@ resource "tencentcloud_postgresql_instance" "test" {
363401 }
364402}
365403`
404+ const testAccPostgresqlInstancePostpaid = defaultVpcSubnets + `
405+ data "tencentcloud_availability_zones_by_product" "zone" {
406+ product = "postgres"
407+ }
408+
409+ data "tencentcloud_security_groups" "internal" {
410+ name = "default"
411+ }
412+
413+ locals {
414+ sg_id = data.tencentcloud_security_groups.internal.security_groups.0.security_group_id
415+ }
416+
417+ resource "tencentcloud_postgresql_instance" "test" {
418+ name = "tf_postsql_postpaid"
419+ availability_zone = var.default_az
420+ charge_type = "POSTPAID_BY_HOUR"
421+ period = 1
422+ vpc_id = local.vpc_id
423+ subnet_id = local.subnet_id
424+ engine_version = "13.3"
425+ root_password = "t1qaA2k1wgvfa3?ZZZ"
426+ security_groups = [local.sg_id]
427+ charset = "LATIN1"
428+ project_id = 0
429+ memory = 2
430+ storage = 20
431+ }`
432+
433+ const testAccPostgresqlInstancePostpaid_to_Prepaid = defaultVpcSubnets + `
434+ data "tencentcloud_availability_zones_by_product" "zone" {
435+ product = "postgres"
436+ }
437+
438+ data "tencentcloud_security_groups" "internal" {
439+ name = "default"
440+ }
441+
442+ locals {
443+ sg_id = data.tencentcloud_security_groups.internal.security_groups.0.security_group_id
444+ }
445+
446+ resource "tencentcloud_postgresql_instance" "test" {
447+ name = "tf_postsql_postpaid_updated_to_prepaid"
448+ availability_zone = var.default_az
449+ charge_type = "PREPAID"
450+ period = 2
451+ vpc_id = local.vpc_id
452+ subnet_id = local.subnet_id
453+ engine_version = "13.3"
454+ root_password = "t1qaA2k1wgvfa3?ZZZ"
455+ security_groups = [local.sg_id]
456+ charset = "LATIN1"
457+ project_id = 0
458+ memory = 2
459+ storage = 20
460+ }`
366461
367462const testAccPostgresqlInstancePrepaid = defaultVpcSubnets + `
368463data "tencentcloud_availability_zones_by_product" "zone" {
0 commit comments