@@ -24,6 +24,8 @@ resource "tencentcloud_waf_clb_instance" "example" {
2424 time_unit = "m"
2525 auto_renew_flag = 1
2626 elastic_mode = 1
27+ bot_management = 1
28+ api_security = 1
2729}
2830```
2931
@@ -38,6 +40,8 @@ resource "tencentcloud_waf_clb_instance" "example" {
3840 auto_renew_flag = 1
3941 elastic_mode = 1
4042 qps_limit = 200000
43+ bot_management = 1
44+ api_security = 1
4145}
4246```
4347*/
@@ -109,6 +113,20 @@ func resourceTencentCloudWafClbInstance() *schema.Resource {
109113 ValidateFunc : validateIntegerMin (10000 ),
110114 Description : "QPS Limit, Minimum setting 10000. Only `elastic_mode` is 1, can be set." ,
111115 },
116+ "bot_management" : {
117+ Optional : true ,
118+ Type : schema .TypeInt ,
119+ Default : BOT_MANAGEMENT_STATUS_0 ,
120+ ValidateFunc : validateAllowedIntValue (BOT_MANAGEMENT_STATUS ),
121+ Description : "Whether to purchase Bot management, 1: yes, 0: no. Default is 0." ,
122+ },
123+ "api_security" : {
124+ Optional : true ,
125+ Type : schema .TypeInt ,
126+ Default : API_SECURITY_STATUS_0 ,
127+ ValidateFunc : validateAllowedIntValue (API_SECURITY_STATUS ),
128+ Description : "Whether to purchase API Security, 1: yes, 0: no. Default is 0." ,
129+ },
112130 //"domain_pkg_count": {
113131 // Optional: true,
114132 // Type: schema.TypeInt,
@@ -142,11 +160,6 @@ func resourceTencentCloudWafClbInstance() *schema.Resource {
142160 Type : schema .TypeString ,
143161 Description : "waf instance valid time." ,
144162 },
145- "api_security" : {
146- Computed : true ,
147- Type : schema .TypeInt ,
148- Description : "waf instance api security status." ,
149- },
150163 "status" : {
151164 Computed : true ,
152165 Type : schema .TypeInt ,
@@ -161,12 +174,13 @@ func resourceTencentCloudWafClbInstanceCreate(d *schema.ResourceData, meta inter
161174 defer inconsistentCheck (d , meta )()
162175
163176 var (
164- logId = getLogId (contextNil )
165- request = waf .NewGenerateDealsAndPayNewRequest ()
166- response = waf .NewGenerateDealsAndPayNewResponse ()
167- client = meta .(* TencentCloudClient ).apiV3Conn
168- instanceId string
169- mainlandMode int
177+ logId = getLogId (contextNil )
178+ request = waf .NewGenerateDealsAndPayNewRequest ()
179+ response = waf .NewGenerateDealsAndPayNewResponse ()
180+ client = meta .(* TencentCloudClient ).apiV3Conn
181+ instanceId string
182+ mainlandMode int
183+ goodsCategory string
170184 )
171185
172186 region := client .Region
@@ -187,7 +201,7 @@ func resourceTencentCloudWafClbInstanceCreate(d *schema.ResourceData, meta inter
187201 instanceGoodDetail := new (waf.GoodsDetailNew )
188202 instanceGood .GoodsNum = helper .IntInt64 (1 )
189203 if v , ok := d .GetOk ("goods_category" ); ok {
190- goodsCategory : = v .(string )
204+ goodsCategory = v .(string )
191205 goodsCategoryId := int64 (WAF_CATEGORY_ID_CLB [goodsCategory ])
192206 subProductCode := SUB_PRODUCT_CODE_CLB [goodsCategory ]
193207 labelTypes := LABEL_TYPES_CLB [goodsCategory ]
@@ -221,7 +235,63 @@ func resourceTencentCloudWafClbInstanceCreate(d *schema.ResourceData, meta inter
221235 instanceGood .GoodsDetail = instanceGoodDetail
222236 goods = append (goods , instanceGood )
223237
224- //// make domain pkg
238+ // bot management
239+ if v , ok := d .GetOkExists ("bot_management" ); ok {
240+ if v .(int ) == 1 {
241+ botManagementGood := new (waf.GoodNews )
242+ botManagementDetail := new (waf.GoodsDetailNew )
243+ botManagementGood .GoodsCategoryId = helper .IntInt64 (BOT_MANAGEMENT_CATEGORY_ID_CLB )
244+ botManagementGood .GoodsNum = helper .IntInt64 (1 )
245+ botManagementDetail .SubProductCode = helper .String (BOT_MANAGEMENT_SUB_PRODUCT_CODE_CLB )
246+ botManagementDetail .Pid = helper .IntInt64 (BOT_MANAGEMENT_PID_CLB )
247+ botManagementDetail .LabelTypes = helper .Strings ([]string {BOT_MANAGEMENT_LABEL_TYPES_CLB [mainlandMode ]})
248+ botManagementDetail .LabelCounts = []* int64 {helper .IntInt64 (1 )}
249+
250+ if v , ok := d .GetOkExists ("time_span" ); ok {
251+ botManagementDetail .TimeSpan = helper .IntInt64 (v .(int ))
252+ }
253+
254+ if v , ok := d .GetOk ("time_unit" ); ok {
255+ botManagementDetail .TimeUnit = helper .String (v .(string ))
256+ }
257+
258+ botManagementGood .RegionId = helper .IntInt64 (mainlandMode )
259+ botManagementGood .GoodsDetail = botManagementDetail
260+ goods = append (goods , botManagementGood )
261+ }
262+ }
263+
264+ // api security
265+ if v , ok := d .GetOkExists ("api_security" ); ok {
266+ if v .(int ) == 1 {
267+ apiSecurityGood := new (waf.GoodNews )
268+ apiSecurityDetail := new (waf.GoodsDetailNew )
269+ apiSecurityGood .GoodsCategoryId = helper .IntInt64 (API_SECURITY_CATEGORY_ID_CLB )
270+ apiSecurityGood .GoodsNum = helper .IntInt64 (1 )
271+ apiSecurityDetail .SubProductCode = helper .String (API_SECURITY_SUB_PRODUCT_CODE_CLB )
272+ apiSecurityDetail .Pid = helper .IntInt64 (API_SECURITY_PID_CLB )
273+ if mainlandMode == REGION_ID_1 {
274+ apiSecurityDetail .LabelTypes = helper .Strings ([]string {API_SECURITY_LABEL_TYPES_CLB_REGION1 [goodsCategory ]})
275+ } else {
276+ apiSecurityDetail .LabelTypes = helper .Strings ([]string {API_SECURITY_LABEL_TYPES_CLB_REGION9 [goodsCategory ]})
277+ }
278+ apiSecurityDetail .LabelCounts = []* int64 {helper .IntInt64 (1 )}
279+
280+ if v , ok := d .GetOkExists ("time_span" ); ok {
281+ apiSecurityDetail .TimeSpan = helper .IntInt64 (v .(int ))
282+ }
283+
284+ if v , ok := d .GetOk ("time_unit" ); ok {
285+ apiSecurityDetail .TimeUnit = helper .String (v .(string ))
286+ }
287+
288+ apiSecurityGood .RegionId = helper .IntInt64 (mainlandMode )
289+ apiSecurityGood .GoodsDetail = apiSecurityDetail
290+ goods = append (goods , apiSecurityGood )
291+ }
292+ }
293+
294+ // make domain pkg
225295 //if v, ok := d.GetOkExists("domain_pkg_count"); ok {
226296 // domainPkgGood := new(waf.GoodNews)
227297 // domainPkgGoodDetail := new(waf.GoodsDetailNew)
@@ -248,8 +318,8 @@ func resourceTencentCloudWafClbInstanceCreate(d *schema.ResourceData, meta inter
248318 // domainPkgGood.GoodsDetail = domainPkgGoodDetail
249319 // goods = append(goods, domainPkgGood)
250320 //}
251- //
252- //// make qps pkg
321+
322+ // make qps pkg
253323 //if v, ok := d.GetOkExists("qps_pkg_count"); ok {
254324 // qpsPkgGood := new(waf.GoodNews)
255325 // qpsPkgGoodDetail := new(waf.GoodsDetailNew)
@@ -400,6 +470,18 @@ func resourceTencentCloudWafClbInstanceRead(d *schema.ResourceData, meta interfa
400470 _ = d .Set ("qps_limit" , instanceInfo .ElasticBilling )
401471 }
402472
473+ if instanceInfo .BotPkg != nil {
474+ _ = d .Set ("bot_management" , instanceInfo .BotPkg .Status )
475+ } else {
476+ _ = d .Set ("bot_management" , 0 )
477+ }
478+
479+ if instanceInfo .ApiPkg != nil {
480+ _ = d .Set ("api_security" , instanceInfo .ApiPkg .Status )
481+ } else {
482+ _ = d .Set ("api_security" , 0 )
483+ }
484+
403485 //if instanceInfo.DomainPkg != nil {
404486 // _ = d.Set("domain_pkg_count", instanceInfo.DomainPkg.Count)
405487 //}
@@ -421,10 +503,6 @@ func resourceTencentCloudWafClbInstanceRead(d *schema.ResourceData, meta interfa
421503 _ = d .Set ("valid_time" , instanceInfo .ValidTime )
422504 }
423505
424- if instanceInfo .APISecurity != nil {
425- _ = d .Set ("api_security" , instanceInfo .APISecurity )
426- }
427-
428506 if instanceInfo .Status != nil {
429507 _ = d .Set ("status" , instanceInfo .Status )
430508 }
@@ -445,7 +523,7 @@ func resourceTencentCloudWafClbInstanceUpdate(d *schema.ResourceData, meta inter
445523 elasticMode int
446524 )
447525
448- immutableArgs := []string {"goods_category" , "time_span" , "time_unit" , "domain_pkg_count" , "qps_pkg_count" }
526+ immutableArgs := []string {"goods_category" , "time_span" , "time_unit" , "domain_pkg_count" , "qps_pkg_count" , "bot_management" , "api_security" }
449527
450528 for _ , v := range immutableArgs {
451529 if d .HasChange (v ) {
0 commit comments