@@ -168,6 +168,42 @@ func TestAccTencentCloudPostgresqlInstanceResource(t *testing.T) {
168168 })
169169}
170170
171+ func TestAccTencentCloudPostgresqlInstanceResource_prepaid (t * testing.T ) {
172+ resource .Test (t , resource.TestCase {
173+ PreCheck : func () { testAccPreCheckCommon (t , ACCOUNT_TYPE_PREPAY ) },
174+ Providers : testAccProviders ,
175+ CheckDestroy : testAccCheckPostgresqlInstanceDestroy ,
176+ Steps : []resource.TestStep {
177+ {
178+ Config : testAccPostgresqlInstancePrepaid ,
179+ Check : resource .ComposeTestCheckFunc (
180+ testAccCheckPostgresqlInstanceExists (testPostgresqlInstanceResourceKey ),
181+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "id" ),
182+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "name" , "tf_postsql_pre" ),
183+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "charge_type" , "PREPAID" ),
184+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "vpc_id" ),
185+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "subnet_id" ),
186+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "memory" , "2" ),
187+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "storage" , "50" ),
188+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "create_time" ),
189+ resource .TestCheckResourceAttr (testPostgresqlInstanceResourceKey , "public_access_switch" , "false" ),
190+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "availability_zone" ),
191+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "private_access_ip" ),
192+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "private_access_port" ),
193+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "db_major_vesion" ),
194+ resource .TestCheckResourceAttrSet (testPostgresqlInstanceResourceKey , "db_major_version" ),
195+ ),
196+ },
197+ {
198+ ResourceName : testPostgresqlInstanceResourceKey ,
199+ ImportState : true ,
200+ ImportStateVerify : true ,
201+ ImportStateVerifyIgnore : []string {"root_password" , "spec_code" , "public_access_switch" , "charset" , "backup_plan" },
202+ },
203+ },
204+ })
205+ }
206+
171207func TestAccTencentCloudPostgresqlInstanceResource_MAZ (t * testing.T ) {
172208 t .Parallel ()
173209 resource .Test (t , resource.TestCase {
@@ -289,6 +325,34 @@ resource "tencentcloud_postgresql_instance" "test" {
289325}
290326`
291327
328+ const testAccPostgresqlInstancePrepaid = defaultVpcSubnets + `
329+ data "tencentcloud_availability_zones_by_product" "zone" {
330+ product = "postgres"
331+ }
332+
333+ data "tencentcloud_security_groups" "internal" {
334+ name = "default"
335+ }
336+
337+ locals {
338+ sg_id = data.tencentcloud_security_groups.internal.security_groups.0.security_group_id
339+ }
340+
341+ resource "tencentcloud_postgresql_instance" "test" {
342+ name = "tf_postsql_pre"
343+ availability_zone = data.tencentcloud_availability_zones_by_product.zone.zones[5].name
344+ charge_type = "PREPAID"
345+ vpc_id = local.vpc_id
346+ subnet_id = local.subnet_id
347+ engine_version = "10.4"
348+ root_password = "t1qaA2k1wgvfa3?ZZZ"
349+ security_groups = [local.sg_id]
350+ charset = "LATIN1"
351+ project_id = 0
352+ memory = 2
353+ storage = 50
354+ }`
355+
292356const testAccPostgresqlInstanceOpenPublic string = testAccPostgresqlInstanceBasic + defaultVpcSubnets + `
293357resource "tencentcloud_postgresql_instance" "test" {
294358 name = "tf_postsql_instance_update"
0 commit comments