Skip to content

Commit 9e9810c

Browse files
adcoelhotobio
andauthored
[ResponseOps] Maintenance window resource (#1224)
* Maintenance window resource: - uses the plugin framework - client generating the openApi specification * make docs-generate * Change float32s to int32s * Simplify model code. * Resource tests * Update the changelog. * Fix diags and resource tests. * Missing tests. * error handling * PR fixes * improved documentation * version and serverless checks * Addressing PR comments 1 * Use EnforceMinVersion in maintenance_window/create.go Co-authored-by: Toby Brain <tobio85@gmail.com> * Generating docs * fix linter * Moving validation around. * Use terraform-plugin-testing * add iso8601 validation * restructure maintenance window model code * call read after update/create * fix empty recurring field * fix terraform import * Update internal/kibana/maintenance_window/resource.go Co-authored-by: Toby Brain <tobio85@gmail.com> * Addressing PR comments 2 * change schema description * Addressing PR comments. * fix tests --------- Co-authored-by: Toby Brain <tobio85@gmail.com>
1 parent 764c8cd commit 9e9810c

File tree

27 files changed

+3142
-25
lines changed

27 files changed

+3142
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ website/node_modules
2626
*.test
2727
*.iml
2828
*.vscode
29+
__debug_*
2930

3031
website/vendor
3132

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## [Unreleased]
22

3+
- Create `elasticstack_kibana_maintenance_window` resource. ([#1224](https://github.com/elastic/terraform-provider-elasticstack/pull/1224))
34
- Add support for `solution` field in `elasticstack_kibana_space` resource and data source ([#1102](https://github.com/elastic/terraform-provider-elasticstack/issues/1102))
45
- Add `slo_id` validation to `elasticstack_kibana_slo` ([#1221](https://github.com/elastic/terraform-provider-elasticstack/pull/1221))
56
- Add `ignore_missing_component_templates` to `elasticstack_elasticsearch_index_template` ([#1206](https://github.com/elastic/terraform-provider-elasticstack/pull/1206))
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
---
2+
subcategory: "Kibana"
3+
layout: ""
4+
page_title: "Elasticstack: elasticstack_kibana_maintenance_window Resource"
5+
description: |-
6+
Manages Kibana maintenance windows.
7+
---
8+
9+
# Resource: elasticstack_kibana_maintenance_window
10+
11+
Creates and manages Kibana [maintenance windows](https://www.elastic.co/docs/api/doc/kibana/group/endpoint-maintenance-window)
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "elasticstack" {
17+
elasticsearch {}
18+
kibana {}
19+
}
20+
21+
resource "elasticstack_kibana_maintenance_window" "my_maintenance_window" {
22+
title = "UPDATE TEST"
23+
enabled = true
24+
25+
custom_schedule = {
26+
start = "1993-01-01T05:00:00.200Z"
27+
duration = "12d"
28+
29+
recurring = {
30+
every = "21d"
31+
on_week_day = ["MO", "+3TU", "-2FR"]
32+
on_month_day = [1, 2, 4, 6, 7]
33+
on_month = [12]
34+
}
35+
}
36+
37+
scope = {
38+
alerting = {
39+
kql = "_id: '1234'"
40+
}
41+
}
42+
}
43+
```
44+
45+
<!-- schema generated by tfplugindocs -->
46+
## Schema
47+
48+
### Required
49+
50+
- `custom_schedule` (Attributes) A set schedule over which the maintenance window applies. (see [below for nested schema](#nestedatt--custom_schedule))
51+
- `title` (String) The name of the maintenance window.
52+
53+
### Optional
54+
55+
- `enabled` (Boolean) Whether the current maintenance window is enabled.
56+
- `scope` (Attributes) An object that narrows the scope of what is affected by this maintenance window. (see [below for nested schema](#nestedatt--scope))
57+
- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used.
58+
59+
### Read-Only
60+
61+
- `id` (String) Generated ID for the maintenance window.
62+
63+
<a id="nestedatt--custom_schedule"></a>
64+
### Nested Schema for `custom_schedule`
65+
66+
Required:
67+
68+
- `duration` (String) The duration of the schedule. It allows values in `<integer><unit>` format. `<unit>` is one of `d`, `h`, `m`, or `s` for days, hours, minutes, seconds. For example: `1d`, `5h`, `30m`, `5000s`.
69+
- `recurring` (Attributes) A set schedule over which the maintenance window applies. (see [below for nested schema](#nestedatt--custom_schedule--recurring))
70+
- `start` (String) The start date and time of the schedule, provided in ISO 8601 format and set to the UTC timezone. For example: `2025-03-12T12:00:00.000Z`.
71+
72+
Optional:
73+
74+
- `timezone` (String) The timezone of the schedule. The default timezone is UTC.
75+
76+
<a id="nestedatt--custom_schedule--recurring"></a>
77+
### Nested Schema for `custom_schedule.recurring`
78+
79+
Optional:
80+
81+
- `end` (String) The end date and time of the schedule, provided in ISO 8601 format and set to the UTC timezone. For example: `2025-03-12T12:00:00.000Z`.
82+
- `every` (String) The duration of the schedule. It allows values in `<integer><unit>` format. `<unit>` is one of `d`, `h`, `m`, or `s` for days, hours, minutes, seconds. For example: `1d`, `5h`, `30m`, `5000s`.
83+
- `occurrences` (Number) The total number of recurrences of the schedule.
84+
- `on_month` (List of Number) The specific months for a recurring schedule. Valid values are 1-12.
85+
- `on_month_day` (List of Number) The specific days of the month for a recurring schedule. Valid values are 1-31.
86+
- `on_week_day` (List of String) The specific days of the week (`[MO,TU,WE,TH,FR,SA,SU]`) or nth day of month (`[+1MO, -3FR, +2WE, -4SA, -5SU]`) for a recurring schedule.
87+
88+
89+
90+
<a id="nestedatt--scope"></a>
91+
### Nested Schema for `scope`
92+
93+
Required:
94+
95+
- `alerting` (Attributes) A set schedule over which the maintenance window applies. (see [below for nested schema](#nestedatt--scope--alerting))
96+
97+
<a id="nestedatt--scope--alerting"></a>
98+
### Nested Schema for `scope.alerting`
99+
100+
Required:
101+
102+
- `kql` (String) A filter written in Kibana Query Language (KQL).
103+
104+
## Import
105+
106+
Import is supported using the following syntax:
107+
108+
```shell
109+
terraform import elasticstack_kibana_maintenance_window.my_maintenance_window <space id>/<maintenance window id>
110+
```
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
terraform import elasticstack_kibana_maintenance_window.my_maintenance_window <space id>/<maintenance window id>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
provider "elasticstack" {
2+
elasticsearch {}
3+
kibana {}
4+
}
5+
6+
resource "elasticstack_kibana_maintenance_window" "my_maintenance_window" {
7+
title = "UPDATE TEST"
8+
enabled = true
9+
10+
custom_schedule = {
11+
start = "1993-01-01T05:00:00.200Z"
12+
duration = "12d"
13+
14+
recurring = {
15+
every = "21d"
16+
on_week_day = ["MO", "+3TU", "-2FR"]
17+
on_month_day = [1, 2, 4, 6, 7]
18+
on_month = [12]
19+
}
20+
}
21+
22+
scope = {
23+
alerting = {
24+
kql = "_id: '1234'"
25+
}
26+
}
27+
}

0 commit comments

Comments
 (0)