Skip to content

Commit ffbaf8e

Browse files
author
hellertang
authored
fix create read only instance when prepaid (#790)
1 parent 9c85bfb commit ffbaf8e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tencentcloud/resource_tc_mysql_readonly_instance.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,14 @@ func mysqlCreateReadonlyInstancePayByMonth(ctx context.Context, d *schema.Resour
7070
instanceRole := "ro"
7171
request.InstanceRole = &instanceRole
7272

73-
period := int64(d.Get("period").(int))
74-
request.Period = &period
73+
payType, ok := d.GetOk("pay_type")
74+
var period int
75+
if !ok || payType == -1 {
76+
period = d.Get("prepaid_period").(int)
77+
} else {
78+
period = d.Get("period").(int)
79+
}
80+
request.Period = helper.IntInt64(period)
7581

7682
autoRenewFlag := int64(d.Get("auto_renew_flag").(int))
7783
request.AutoRenewFlag = &autoRenewFlag

0 commit comments

Comments
 (0)