Skip to content

Commit ce159be

Browse files
thecraftmanclaude
andcommitted
feat(monitor): expose disabled attribute on axiom_monitor
The provider previously did not expose the monitor `disabled` flag. Since axiom-go marshals `disabled` with no `omitempty`, every create/update sent `"disabled": false`, re-enabling monitors that had been disabled in the UI on each `terraform apply`. Add `disabled` as an Optional+Computed boolean attribute (default false), wired through extractMonitorResourceModel and flattenMonitor, and regenerate the resource/data-source docs. Users can now set `disabled = true` to manage the state in Terraform, or use `lifecycle { ignore_changes = [disabled] }` to let the UI own it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 191d514 commit ce159be

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

axiom/resource_monitor.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ type MonitorResourceModel struct {
4747
NotifyByGroup types.Bool `tfsdk:"notify_by_group"`
4848
APLQuery types.String `tfsdk:"apl_query"`
4949
MPLQuery types.String `tfsdk:"mpl_query"`
50+
Disabled types.Bool `tfsdk:"disabled"`
5051
DisabledUntil types.String `tfsdk:"disabled_until"`
5152
IntervalMinutes types.Int64 `tfsdk:"interval_minutes"`
5253
NotifierIds types.List `tfsdk:"notifier_ids"`
@@ -119,6 +120,12 @@ func (r *MonitorResource) Schema(_ context.Context, _ resource.SchemaRequest, re
119120
}...),
120121
},
121122
},
123+
"disabled": schema.BoolAttribute{
124+
MarkdownDescription: "Whether the monitor is disabled. When true, the monitor will not run or trigger alerts until re-enabled.",
125+
Optional: true,
126+
Computed: true,
127+
Default: booldefault.StaticBool(false),
128+
},
122129
"disabled_until": schema.StringAttribute{
123130
MarkdownDescription: "The time the monitor will be disabled until",
124131
Optional: true,
@@ -413,6 +420,7 @@ func extractMonitorResourceModel(ctx context.Context, plan MonitorResourceModel)
413420
APLQuery: aplQuery,
414421
MPLQuery: mplQuery,
415422
Description: plan.Description.ValueString(),
423+
Disabled: plan.Disabled.ValueBool(),
416424
DisabledUntil: disabledUntil,
417425
Interval: time.Duration(plan.IntervalMinutes.ValueInt64() * int64(time.Minute)),
418426
NotifierIDs: notifierIds,
@@ -477,6 +485,7 @@ func flattenMonitor(monitor *axiom.Monitor, currentState *MonitorResourceModel)
477485
NotifyByGroup: types.BoolValue(monitor.NotifyByGroup),
478486
APLQuery: aplQuery,
479487
MPLQuery: mplQuery,
488+
Disabled: types.BoolValue(monitor.Disabled),
480489
DisabledUntil: disabledUntil,
481490
IntervalMinutes: types.Int64Value(int64(monitor.Interval.Minutes())),
482491
NotifierIds: flattenStringSlice(monitor.NotifierIDs),

docs/data-sources/monitor.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ description: |-
2828
- `created_by` (String) The ID of the user who created the monitor
2929
- `delay` (Number) The delay in seconds before the monitor runs (useful for situations where data is batched/delayed)
3030
- `description` (String) Monitor description
31+
- `disabled` (Boolean) Whether the monitor is disabled. When true, the monitor will not run or trigger alerts until re-enabled.
3132
- `disabled_until` (String) The time the monitor will be disabled until
3233
- `interval_minutes` (Number) How often the monitor should run
3334
- `mpl_query` (String) The MPL query used inside the monitor (mutually exclusive with apl_query)

docs/resources/monitor.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ description: |-
2727
- `compare_days` (Number) The number of days to compare for anomaly detection
2828
- `delay` (Number) The delay in seconds before the monitor runs (useful for situations where data is batched/delayed)
2929
- `description` (String) Monitor description
30+
- `disabled` (Boolean) Whether the monitor is disabled. When true, the monitor will not run or trigger alerts until re-enabled.
3031
- `disabled_until` (String) The time the monitor will be disabled until
3132
- `interval_minutes` (Number) How often the monitor should run
3233
- `mpl_query` (String) The MPL query used inside the monitor (mutually exclusive with apl_query)

0 commit comments

Comments
 (0)