@@ -173,6 +173,7 @@ func resourceTencentMonitorAlarmPolicy() *schema.Resource {
173
173
Type : schema .TypeList ,
174
174
Optional : true ,
175
175
MaxItems : 1 ,
176
+ Computed : true ,
176
177
Description : "A list of metric trigger condition." ,
177
178
Elem : & schema.Resource {
178
179
Schema : map [string ]* schema.Schema {
@@ -196,6 +197,7 @@ func resourceTencentMonitorAlarmPolicy() *schema.Resource {
196
197
"event_conditions" : {
197
198
Type : schema .TypeList ,
198
199
Optional : true ,
200
+ Computed : true ,
199
201
Description : "A list of event trigger condition." ,
200
202
Elem : & schema.Resource {
201
203
Schema : AlarmPolicyRule (),
@@ -457,31 +459,32 @@ func resourceTencentMonitorAlarmPolicyRead(d *schema.ResourceData, meta interfac
457
459
d .Set ("update_time" , policy .UpdateTime ),
458
460
)
459
461
460
- var conditions = map [string ]interface {}{}
461
- conditions ["is_union_rule" ] = policy .Condition .IsUnionRule
462
462
var rules = make ([]interface {}, 0 , 100 )
463
463
for _ , rule := range policy .Condition .Rules {
464
- m := map [string ]interface {}{}
465
- m ["metrics_name" ] = rule .MetricName
466
- m ["period" ] = rule .Period
467
- m ["operator" ] = rule .Operator
468
- m ["value" ] = rule .Value
469
- m ["continue_period" ] = rule .ContinuePeriod
470
- m ["notice_frequency" ] = rule .NoticeFrequency
471
- m ["is_power_notice" ] = rule .IsPowerNotice
472
- m ["notice_frequency" ] = rule .NoticeFrequency
473
- m ["description" ] = rule .Description
474
- m ["unit" ] = rule .Unit
475
- m ["rule_type" ] = rule .RuleType
464
+ m := map [string ]interface {}{
465
+ "metric_name" : rule .MetricName ,
466
+ "period" : rule .Period ,
467
+ "operator" : rule .Operator ,
468
+ "value" : rule .Value ,
469
+ "continue_period" : rule .ContinuePeriod ,
470
+ "notice_frequency" : rule .NoticeFrequency ,
471
+ "description" : rule .Description ,
472
+ "unit" : rule .Unit ,
473
+ "rule_type" : rule .RuleType ,
474
+ }
476
475
rules = append (rules , m )
477
476
}
478
- conditions ["rules" ] = rules
479
- errs = append (errs , d .Set ("conditions" , conditions ))
480
477
481
- var eventConditions = make ([]interface {}, 0 , 100 )
478
+ conditions := map [string ]interface {}{
479
+ "is_union_rule" : policy .Condition .IsUnionRule ,
480
+ "rules" : rules ,
481
+ }
482
+ _ = d .Set ("conditions" , []interface {}{conditions })
483
+
484
+ eventConditions := make ([]map [string ]interface {}, 0 , len (policy .EventCondition .Rules ))
482
485
for _ , eventRule := range policy .EventCondition .Rules {
483
- m := map [string ]interface {}{}
484
- m ["metrics_name " ] = eventRule .MetricName
486
+ m := make ( map [string ]interface {}, 5 )
487
+ m ["metric_name " ] = eventRule .MetricName
485
488
m ["period" ] = eventRule .Period
486
489
m ["operator" ] = eventRule .Operator
487
490
m ["value" ] = eventRule .Value
@@ -494,8 +497,7 @@ func resourceTencentMonitorAlarmPolicyRead(d *schema.ResourceData, meta interfac
494
497
m ["rule_type" ] = eventRule .RuleType
495
498
eventConditions = append (eventConditions , m )
496
499
}
497
- errs = append (errs , d .Set ("event_conditions" , eventConditions ))
498
-
500
+ _ = d .Set ("event_conditions" , eventConditions )
499
501
var noticeIds = make ([]interface {}, 0 , 100 )
500
502
for _ , notice := range policy .NoticeIds {
501
503
noticeIds = append (noticeIds , notice )
0 commit comments