@@ -34,19 +34,19 @@ func ResourceTencentCloudLiteHbaseInstance() *schema.Resource {
34
34
"pay_mode" : {
35
35
Type : schema .TypeInt ,
36
36
Required : true ,
37
- Description : "Instance pay mode. Value range: 0: indicates post pay mode, that is, pay-as-you-go." ,
37
+ Description : "Instance pay mode. Value range: 0: indicates post- pay mode, that is, pay-as-you-go. 1: indicates pre-pay mode, that is, monthly subscription ." ,
38
38
},
39
39
40
40
"disk_type" : {
41
41
Type : schema .TypeString ,
42
42
Required : true ,
43
- Description : "Instance disk type, fill in CLOUD_HSSD to indicate performance cloud storage." ,
43
+ Description : "Instance disk type, Value range: CLOUD_HSSD: indicate performance cloud storage(ESSD). CLOUD_BSSD: indicate standard cloud storage(SSD) ." ,
44
44
},
45
45
46
46
"disk_size" : {
47
47
Type : schema .TypeInt ,
48
48
Required : true ,
49
- Description : "Instance single-node disk capacity, in GB. The single-node disk capacity must be greater than or equal to 100 and less than or equal to 10000, with an adjustment step size of 20 ." ,
49
+ Description : "Instance single-node disk capacity, in GB. The single-node disk capacity must be greater than or equal to 100 and less than or equal to 250 times the number of CPU cores. The capacity adjustment step is 100 ." ,
50
50
},
51
51
52
52
"node_type" : {
@@ -114,6 +114,23 @@ func ResourceTencentCloudLiteHbaseInstance() *schema.Resource {
114
114
},
115
115
},
116
116
},
117
+
118
+ "time_span" : {
119
+ Type : schema .TypeInt ,
120
+ Optional : true ,
121
+ Description : "Time span." ,
122
+ },
123
+ "time_unit" : {
124
+ Type : schema .TypeString ,
125
+ Optional : true ,
126
+ Description : "Time unit, fill in m which means month." ,
127
+ },
128
+ "auto_renew_flag" : {
129
+ Type : schema .TypeInt ,
130
+ Optional : true ,
131
+ Computed : true ,
132
+ Description : "AutoRenewFlag, Value range: 0: indicates NOTIFY_AND_MANUAL_RENEW; 1: indicates NOTIFY_AND_AUTO_RENEW; 2: indicates DISABLE_NOTIFY_AND_MANUAL_RENEW." ,
133
+ },
117
134
},
118
135
}
119
136
}
@@ -189,6 +206,31 @@ func resourceTencentCloudLiteHbaseInstanceCreate(d *schema.ResourceData, meta in
189
206
}
190
207
}
191
208
209
+ var prePaySetting * emr.PrePaySetting
210
+ if v , ok := d .GetOk ("time_span" ); ok {
211
+ prePaySetting = & emr.PrePaySetting {}
212
+ prePaySetting .Period = & emr.Period {}
213
+ prePaySetting .Period .TimeSpan = helper .IntInt64 (v .(int ))
214
+ }
215
+ if v , ok := d .GetOk ("time_unit" ); ok {
216
+ if prePaySetting == nil {
217
+ prePaySetting = & emr.PrePaySetting {}
218
+ }
219
+ if prePaySetting .Period == nil {
220
+ prePaySetting .Period = & emr.Period {}
221
+ }
222
+ prePaySetting .Period .TimeUnit = helper .String (v .(string ))
223
+ }
224
+ if v , ok := d .GetOk ("auto_renew_flag" ); ok {
225
+ if prePaySetting == nil {
226
+ prePaySetting = & emr.PrePaySetting {}
227
+ }
228
+ prePaySetting .AutoRenewFlag = helper .IntInt64 (v .(int ))
229
+ }
230
+ if prePaySetting != nil {
231
+ request .PrePaySetting = prePaySetting
232
+ }
233
+
192
234
err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
193
235
result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseEmrClient ().CreateSLInstanceWithContext (ctx , request )
194
236
if e != nil {
@@ -267,10 +309,6 @@ func resourceTencentCloudLiteHbaseInstanceRead(d *schema.ResourceData, meta inte
267
309
_ = d .Set ("disk_size" , respData .DiskSize )
268
310
}
269
311
270
- if respData .NodeType != nil {
271
- _ = d .Set ("node_type" , respData .NodeType )
272
- }
273
-
274
312
zoneSettingsList := make ([]map [string ]interface {}, 0 , len (respData .ZoneSettings ))
275
313
if respData .ZoneSettings != nil {
276
314
for _ , zoneSettings := range respData .ZoneSettings {
@@ -322,6 +360,9 @@ func resourceTencentCloudLiteHbaseInstanceRead(d *schema.ResourceData, meta inte
322
360
323
361
_ = d .Set ("tags" , tagsList )
324
362
}
363
+ if respData .AutoRenewFlag != nil {
364
+ _ = d .Set ("auto_renew_flag" , respData .AutoRenewFlag )
365
+ }
325
366
326
367
_ = instanceId
327
368
return nil
@@ -335,7 +376,7 @@ func resourceTencentCloudLiteHbaseInstanceUpdate(d *schema.ResourceData, meta in
335
376
336
377
ctx := tccommon .NewResourceLifeCycleHandleFuncContext (context .Background (), logId , d , meta )
337
378
338
- immutableArgs := []string {"instance_name" , "pay_mode" , "disk_type" , "disk_size" , "node_type" , "tags" }
379
+ immutableArgs := []string {"instance_name" , "pay_mode" , "disk_type" , "disk_size" , "node_type" , "tags" , "time_span" , "time_unit" , "auto_renew_flag" }
339
380
for _ , v := range immutableArgs {
340
381
if d .HasChange (v ) {
341
382
return fmt .Errorf ("argument `%s` cannot be changed" , v )
@@ -434,9 +475,33 @@ func resourceTencentCloudLiteHbaseInstanceDelete(d *schema.ResourceData, meta in
434
475
log .Printf ("[CRITAL]%s delete lite hbase instance failed, reason:%+v" , logId , err )
435
476
return err
436
477
}
478
+
437
479
emrService := EMRService {
438
480
client : meta .(tccommon.ProviderMeta ).GetAPIV3Conn (),
439
481
}
482
+
483
+ if d .Get ("pay_mode" ).(int ) == 1 {
484
+ conf := tccommon .BuildStateChangeConf ([]string {}, []string {"201" }, 10 * tccommon .ReadRetryTimeout , time .Second , emrService .SLInstanceStateRefreshFunc (instanceId , []string {}))
485
+ if _ , e := conf .WaitForState (); e != nil {
486
+ return e
487
+ }
488
+
489
+ err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
490
+ result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseEmrClient ().TerminateSLInstanceWithContext (ctx , request )
491
+ if e != nil {
492
+ return tccommon .RetryError (e )
493
+ } else {
494
+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
495
+ }
496
+ response = result
497
+ return nil
498
+ })
499
+ if err != nil {
500
+ log .Printf ("[CRITAL]%s delete lite hbase instance failed, reason:%+v" , logId , err )
501
+ return err
502
+ }
503
+ }
504
+
440
505
conf := tccommon .BuildStateChangeConf ([]string {}, []string {"-2" }, 10 * tccommon .ReadRetryTimeout , time .Second , emrService .SLInstanceStateRefreshFunc (instanceId , []string {}))
441
506
if _ , e := conf .WaitForState (); e != nil {
442
507
return e
0 commit comments