Skip to content

Commit 41292b5

Browse files
committed
refactor(monitor_alert_v2): remove deprecated trigger_after_minutes field
1 parent 5a38305 commit 41292b5

File tree

2 files changed

+1
-20
lines changed

2 files changed

+1
-20
lines changed

sysdig/resource_sysdig_monitor_alert_v2_event.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,10 @@ func resourceSysdigMonitorAlertV2Event() *schema.Resource {
3333
},
3434

3535
Schema: createScopedSegmentedAlertV2Schema(createAlertV2Schema(map[string]*schema.Schema{
36-
"trigger_after_minutes": {
37-
Type: schema.TypeInt,
38-
Optional: true,
39-
Computed: true, // computed if range_seconds is defined
40-
Deprecated: "Use range_seconds instead",
41-
ValidateFunc: validation.IntAtLeast(1),
42-
},
4336
"range_seconds": {
4437
Type: schema.TypeInt,
4538
Optional: true,
4639
Computed: true, // computed if trigger_after_minutes is defined
47-
ExactlyOneOf: []string{"trigger_after_minutes"},
4840
ValidateFunc: validation.IntAtLeast(60),
4941
},
5042
"operator": {
@@ -217,15 +209,6 @@ func buildAlertV2EventStruct(d *schema.ResourceData) (*v2.AlertV2Event, error) {
217209
config.Range = d.Get("range_seconds").(int)
218210
}
219211

220-
if d.HasChange("trigger_after_minutes") {
221-
// GetOk returns true even if the value is stored only in the state and not in the user config:
222-
// to avoid applying a trigger_after_minutes old value from the state even if the user removed it from the config
223-
// we use HasChange that is true only if the user has changed (or created) it - and so it must be in the config
224-
if attr, ok := d.GetOk("trigger_after_minutes"); ok && attr != nil {
225-
config.Range = minutesToSeconds(d.Get("trigger_after_minutes").(int))
226-
}
227-
}
228-
229212
alert := &v2.AlertV2Event{
230213
AlertV2Common: *alertV2Common,
231214
Config: config,
@@ -244,7 +227,6 @@ func updateAlertV2EventState(d *schema.ResourceData, alert *v2.AlertV2Event) err
244227
return err
245228
}
246229

247-
_ = d.Set("trigger_after_minutes", secondsToMinutes(alert.Config.Range))
248230
_ = d.Set("range_seconds", alert.Config.Range)
249231

250232
_ = d.Set("operator", alert.Config.ConditionOperator)

website/docs/r/monitor_alert_v2_event.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ These arguments are common to all alerts in Sysdig Monitor.
5757

5858
* `name` - (Required) The name of the alert rule. It must be unique.
5959
* `description` - (Optional) The description of Monitor alert.
60-
* `range_seconds` - (Optional, required if `trigger_after_minutes` is not defined): The time period in seconds over which to count events and trigger an alert if the total exceeds the threshold.
61-
* `trigger_after_minutes` - (Optional, Deprecated) The time period in minutes over which to count events and trigger an alert if the total exceeds the threshold. Deprecated: use `range_seconds` instead.
60+
* `range_seconds` - (Optional): The time period in seconds over which to count events and trigger an alert if the total exceeds the threshold.
6261
* `group` - (Optional) Used to group alert rules in the UI. This value must be a lowercase string.
6362
* `severity` - (Optional) Severity of the Monitor alert. It must be `high`, `medium`, `low` or `info`. Default: `low`.
6463
* `enabled` - (Optional) Boolean that defines if the alert is enabled or not. Default: `true`.

0 commit comments

Comments
 (0)