@@ -57,7 +57,7 @@ func resourceTencentCloudPostgresqlInstance() *schema.Resource {
5757 "charge_type" : {
5858 Type : schema .TypeString ,
5959 Optional : true ,
60- Default : POSTGRESQL_PAYTYPE_POSTPAID ,
60+ Default : COMMON_PAYTYPE_POSTPAID ,
6161 ForceNew : true ,
6262 ValidateFunc : validateAllowedStringValue (POSTGRESQL_PAYTYPE ),
6363 Description : "Pay type of the postgresql instance. For now, only `POSTPAID_BY_HOUR` is valid." ,
@@ -186,11 +186,14 @@ func resourceTencentCloudPostgresqlInstanceCreate(d *schema.ResourceData, meta i
186186 var period = 1
187187 //the sdk asks to set value with 1 when paytype is postpaid
188188
189- if payType == COMMON_PAYTYPE_PREPAID {
190- payType = POSTGRESQL_PAYTYPE_PREPAID
191- } else {
192- payType = POSTGRESQL_PAYTYPE_POSTPAID
193- }
189+ /*
190+ if payType == COMMON_PAYTYPE_PREPAID {
191+ payType = POSTGRESQL_PAYTYPE_PREPAID
192+ } else {
193+ payType = POSTGRESQL_PAYTYPE_POSTPAID
194+ }
195+
196+ */
194197
195198 var instanceId string
196199 var outErr , inErr error
@@ -443,12 +446,14 @@ func resourceTencentCloudPostgresqlInstanceRead(d *schema.ResourceData, meta int
443446 _ = d .Set ("engine_version" , instance .DBVersion )
444447 _ = d .Set ("name" , instance .DBInstanceName )
445448 _ = d .Set ("charset" , instance .DBCharset )
449+ _ = d .Set ("charge_type" , instance .PayType )
446450
447- if * instance .PayType == POSTGRESQL_PAYTYPE_PREPAID {
451+ if * instance .PayType == POSTGRESQL_PAYTYPE_PREPAID || * instance . PayType == COMMON_PAYTYPE_PREPAID {
448452 _ = d .Set ("charge_type" , COMMON_PAYTYPE_PREPAID )
449453 } else {
450454 _ = d .Set ("charge_type" , COMMON_PAYTYPE_POSTPAID )
451455 }
456+
452457 //net status
453458 public_access_switch := false
454459 if len (instance .DBInstanceNetInfo ) > 0 {
@@ -462,7 +467,8 @@ func resourceTencentCloudPostgresqlInstanceRead(d *schema.ResourceData, meta int
462467 _ = d .Set ("public_access_host" , v .Address )
463468 _ = d .Set ("public_access_port" , v .Port )
464469 }
465- if * v .NetType == "private" {
470+ //private or inner will not appear at same time, private for instance with vpc
471+ if (* v .NetType == "private" || * v .NetType == "inner" ) && * v .Ip != "" {
466472 _ = d .Set ("private_access_ip" , v .Ip )
467473 _ = d .Set ("private_access_port" , v .Port )
468474 }
0 commit comments