@@ -114,6 +114,11 @@ func ResourceTencentCloudWafCc() *schema.Resource {
114114 Elem : & schema.Schema {Type : schema .TypeInt },
115115 Description : "Session ID that needs to be enabled for the rule." ,
116116 },
117+ "limit_method" : {
118+ Optional : true ,
119+ Type : schema .TypeString ,
120+ Description : "Frequency limiting method." ,
121+ },
117122 "rule_id" : {
118123 Computed : true ,
119124 Type : schema .TypeString ,
@@ -201,11 +206,17 @@ func resourceTencentCloudWafCcCreate(d *schema.ResourceData, meta interface{}) e
201206 if v , ok := d .GetOk ("session_applied" ); ok {
202207 sessionAppliedSet := v .(* schema.Set ).List ()
203208 for i := range sessionAppliedSet {
204- sessionApplied := sessionAppliedSet [i ].(int )
205- request .SessionApplied = append (request .SessionApplied , helper .IntInt64 (sessionApplied ))
209+ if sessionAppliedSet [i ] != nil {
210+ sessionApplied := sessionAppliedSet [i ].(int )
211+ request .SessionApplied = append (request .SessionApplied , helper .IntInt64 (sessionApplied ))
212+ }
206213 }
207214 }
208215
216+ if v , ok := d .GetOk ("limit_method" ); ok {
217+ request .LimitMethod = helper .String (v .(string ))
218+ }
219+
209220 request .RuleId = helper .IntInt64 (0 )
210221 err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
211222 result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseWafClient ().UpsertCCRule (request )
@@ -215,9 +226,8 @@ func resourceTencentCloudWafCcCreate(d *schema.ResourceData, meta interface{}) e
215226 log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
216227 }
217228
218- if result == nil || result .Response .RuleId == nil {
219- e = fmt .Errorf ("waf cc failed not exists" )
220- return resource .NonRetryableError (e )
229+ if result == nil || result .Response == nil || result .Response .RuleId == nil {
230+ return resource .NonRetryableError (fmt .Errorf ("Create waf cc failed, Response is nil." ))
221231 }
222232
223233 response = result
@@ -313,14 +323,6 @@ func resourceTencentCloudWafCcRead(d *schema.ResourceData, meta interface{}) err
313323 if cc .Options != nil {
314324 _ = d .Set ("options_arr" , cc .Options )
315325 }
316- //
317- //if cc.Edition != nil {
318- // _ = d.Set("edition", cc.Edition)
319- //}
320- //
321- //if cc.Type != nil {
322- // _ = d.Set("type", cc.Type)
323- //}
324326
325327 if cc .EventId != nil {
326328 _ = d .Set ("event_id" , cc .EventId )
@@ -330,6 +332,10 @@ func resourceTencentCloudWafCcRead(d *schema.ResourceData, meta interface{}) err
330332 _ = d .Set ("session_applied" , cc .SessionApplied )
331333 }
332334
335+ if cc .LimitMethod != nil {
336+ _ = d .Set ("limit_method" , cc .LimitMethod )
337+ }
338+
333339 if cc .RuleId != nil {
334340 ruleIdStr := strconv .FormatUint (* cc .RuleId , 10 )
335341 _ = d .Set ("rule_id" , ruleIdStr )
@@ -428,6 +434,10 @@ func resourceTencentCloudWafCcUpdate(d *schema.ResourceData, meta interface{}) e
428434 }
429435 }
430436
437+ if v , ok := d .GetOk ("limit_method" ); ok {
438+ request .LimitMethod = helper .String (v .(string ))
439+ }
440+
431441 err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
432442 result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseWafClient ().UpsertCCRule (request )
433443 if e != nil {
0 commit comments