@@ -53,23 +53,27 @@ func ResourceTencentCloudEbEventTarget() *schema.Resource {
5353 Type : schema .TypeList ,
5454 MaxItems : 1 ,
5555 Optional : true ,
56+ Computed : true ,
5657 Description : "cloud function parameters." ,
5758 Elem : & schema.Resource {
5859 Schema : map [string ]* schema.Schema {
5960 "batch_timeout" : {
6061 Type : schema .TypeInt ,
6162 Optional : true ,
62- Description : "Maximum waiting time for bulk delivery." ,
63+ Computed : true ,
64+ Description : "Maximum waiting time for batch delivery. This parameter is no longer effective, please use the batch_timeout parameter at the outer level." ,
6365 },
6466 "batch_event_count" : {
6567 Type : schema .TypeInt ,
6668 Optional : true ,
67- Description : "Maximum number of events for batch delivery." ,
69+ Computed : true ,
70+ Description : "Maximum number of events for batch delivery. This parameter is no longer effective, please use the batch_event_count parameter at the outer level." ,
6871 },
6972 "enable_batch_delivery" : {
7073 Type : schema .TypeBool ,
7174 Optional : true ,
72- Description : "Enable batch delivery." ,
75+ Computed : true ,
76+ Description : "Enable batch delivery. This parameter is no longer effective, please use the enable_batch_delivery parameter at the outer level." ,
7377 },
7478 },
7579 },
@@ -158,6 +162,27 @@ func ResourceTencentCloudEbEventTarget() *schema.Resource {
158162 Type : schema .TypeString ,
159163 Description : "event rule id." ,
160164 },
165+
166+ "batch_timeout" : {
167+ Type : schema .TypeInt ,
168+ Optional : true ,
169+ Computed : true ,
170+ Description : "Maximum waiting time for batch delivery." ,
171+ },
172+
173+ "batch_event_count" : {
174+ Type : schema .TypeInt ,
175+ Optional : true ,
176+ Computed : true ,
177+ Description : "Maximum number of events for batch delivery." ,
178+ },
179+
180+ "enable_batch_delivery" : {
181+ Type : schema .TypeBool ,
182+ Optional : true ,
183+ Computed : true ,
184+ Description : "Enable batch delivery." ,
185+ },
161186 },
162187 }
163188}
@@ -249,6 +274,18 @@ func resourceTencentCloudEbEventTargetCreate(d *schema.ResourceData, meta interf
249274 request .RuleId = helper .String (v .(string ))
250275 }
251276
277+ if v , ok := d .GetOkExists ("batch_timeout" ); ok {
278+ request .BatchTimeout = helper .IntInt64 (v .(int ))
279+ }
280+
281+ if v , ok := d .GetOkExists ("batch_event_count" ); ok {
282+ request .BatchEventCount = helper .IntInt64 (v .(int ))
283+ }
284+
285+ if v , ok := d .GetOkExists ("enable_batch_delivery" ); ok {
286+ request .EnableBatchDelivery = helper .Bool (v .(bool ))
287+ }
288+
252289 err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
253290 result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseEbClient ().CreateTarget (request )
254291 if e != nil {
@@ -393,6 +430,16 @@ func resourceTencentCloudEbEventTargetRead(d *schema.ResourceData, meta interfac
393430 _ = d .Set ("rule_id" , eventTarget .RuleId )
394431 }
395432
433+ if eventTarget .BatchTimeout != nil {
434+ _ = d .Set ("batch_timeout" , eventTarget .BatchTimeout )
435+ }
436+ if eventTarget .BatchEventCount != nil {
437+ _ = d .Set ("batch_event_count" , eventTarget .BatchEventCount )
438+ }
439+ if eventTarget .EnableBatchDelivery != nil {
440+ _ = d .Set ("enable_batch_delivery" , eventTarget .EnableBatchDelivery )
441+ }
442+
396443 return nil
397444}
398445
@@ -412,10 +459,6 @@ func resourceTencentCloudEbEventTargetUpdate(d *schema.ResourceData, meta interf
412459 ruleId := idSplit [1 ]
413460 targetId := idSplit [2 ]
414461
415- request .EventBusId = & eventBusId
416- request .RuleId = & ruleId
417- request .TargetId = & targetId
418-
419462 immutableArgs := []string {"event_bus_id" , "type" , "target_description" , "rule_id" }
420463
421464 for _ , v := range immutableArgs {
@@ -424,18 +467,37 @@ func resourceTencentCloudEbEventTargetUpdate(d *schema.ResourceData, meta interf
424467 }
425468 }
426469
427- err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
428- result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseEbClient ().UpdateTarget (request )
429- if e != nil {
430- return tccommon .RetryError (e )
431- } else {
432- log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
470+ if d .HasChange ("batch_timeout" ) || d .HasChange ("batch_event_count" ) || d .HasChange ("enable_batch_delivery" ) {
471+
472+ request .EventBusId = & eventBusId
473+ request .RuleId = & ruleId
474+ request .TargetId = & targetId
475+
476+ if v , ok := d .GetOkExists ("batch_timeout" ); ok {
477+ request .BatchTimeout = helper .IntInt64 (v .(int ))
478+ }
479+
480+ if v , ok := d .GetOkExists ("batch_event_count" ); ok {
481+ request .BatchEventCount = helper .IntInt64 (v .(int ))
482+ }
483+
484+ if v , ok := d .GetOkExists ("enable_batch_delivery" ); ok {
485+ request .EnableBatchDelivery = helper .Bool (v .(bool ))
486+ }
487+
488+ err := resource .Retry (tccommon .WriteRetryTimeout , func () * resource.RetryError {
489+ result , e := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseEbClient ().UpdateTarget (request )
490+ if e != nil {
491+ return tccommon .RetryError (e )
492+ } else {
493+ log .Printf ("[DEBUG]%s api[%s] success, request body [%s], response body [%s]\n " , logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
494+ }
495+ return nil
496+ })
497+ if err != nil {
498+ log .Printf ("[CRITAL]%s update eb eventTarget failed, reason:%+v" , logId , err )
499+ return err
433500 }
434- return nil
435- })
436- if err != nil {
437- log .Printf ("[CRITAL]%s update eb eventTarget failed, reason:%+v" , logId , err )
438- return err
439501 }
440502
441503 return resourceTencentCloudEbEventTargetRead (d , meta )
0 commit comments