Skip to content

Commit 14f582c

Browse files
authored
Move settings back to a block to avoid adding yet another breaking change (#1666)
1 parent e247b0a commit 14f582c

File tree

21 files changed

+22
-52
lines changed

21 files changed

+22
-52
lines changed

CHANGELOG.md

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,6 @@ resource "elasticstack_fleet_integration" "tcp-o11y" {
3232
}
3333
```
3434

35-
#### `elasticstack_kibana_slo` `settings` block has change to a an attribute.
36-
37-
As part of migrating this resource to the Terraform plugin framework, the `settings` block has been moved to an attribute. Existing usage of this argument will need to be updated to use an attribute style syntax, for example:
38-
39-
```hcl
40-
resource "elasticstack_kibana_slo" "test_slo" {
41-
...
42-
settings {
43-
sync_delay = "5m"
44-
frequency = "5m"
45-
}
46-
}
47-
```
48-
49-
becomes
50-
51-
```
52-
resource "elasticstack_kibana_slo" "test_slo" {
53-
...
54-
settings = { ## Note the addition of the = here.
55-
sync_delay = "5m"
56-
frequency = "5m"
57-
}
58-
}
59-
```
60-
6135
#### `elasticstack_fleet_integration_policy` input block has changed to a map attribute.
6236

6337
The `input` block in the `elasticstack_fleet_integration_policy` resource has been restructured into the `inputs` map attribute.

docs/resources/kibana_slo.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ resource "elasticstack_kibana_slo" "timeslice_metric" {
249249
- `kql_custom_indicator` (Block List) (see [below for nested schema](#nestedblock--kql_custom_indicator))
250250
- `metric_custom_indicator` (Block List) (see [below for nested schema](#nestedblock--metric_custom_indicator))
251251
- `objective` (Block List) The target objective is the value the SLO needs to meet during the time window. If a timeslices budgeting method is used, we also need to define the timesliceTarget which can be different than the overall SLO target. (see [below for nested schema](#nestedblock--objective))
252-
- `settings` (Attributes) The default settings should be sufficient for most users, but if needed, these properties can be overwritten. (see [below for nested schema](#nestedatt--settings))
252+
- `settings` (Block, Optional) The default settings should be sufficient for most users, but if needed, these properties can be overwritten. (see [below for nested schema](#nestedblock--settings))
253253
- `slo_id` (String) An ID (8 to 48 characters) that contains only letters, numbers, hyphens, and underscores. If omitted, a UUIDv1 will be generated server-side.
254254
- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used.
255255
- `tags` (List of String) The tags for the SLO.
@@ -436,7 +436,7 @@ Optional:
436436
- `timeslice_window` (String)
437437

438438

439-
<a id="nestedatt--settings"></a>
439+
<a id="nestedblock--settings"></a>
440440
### Nested Schema for `settings`
441441

442442
Optional:

internal/kibana/slo/acc_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ func TestAccResourceSlo(t *testing.T) {
8282
resource.TestCheckResourceAttr("elasticstack_kibana_slo.test_slo", "objective.0.target", "0.999"),
8383
resource.TestCheckResourceAttr("elasticstack_kibana_slo.test_slo", "objective.0.timeslice_target", "0.95"),
8484
resource.TestCheckResourceAttr("elasticstack_kibana_slo.test_slo", "objective.0.timeslice_window", "5m"),
85-
resource.TestCheckResourceAttr("elasticstack_kibana_slo.test_slo", "settings.sync_delay", "1m"),
86-
resource.TestCheckResourceAttr("elasticstack_kibana_slo.test_slo", "settings.frequency", "1m"),
8785
resource.TestCheckResourceAttr("elasticstack_kibana_slo.test_slo", "space_id", "default"),
8886
),
8987
},

internal/kibana/slo/models.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ func (m *tfModel) populateFromAPI(apiModel *models.Slo) diag.Diagnostics {
213213
}
214214
m.Objective = []tfObjective{obj}
215215

216-
if apiModel.Settings != nil {
216+
if utils.IsKnown(m.Settings) && apiModel.Settings != nil {
217217
attrValues := map[string]attr.Value{
218218
"sync_delay": types.StringPointerValue(apiModel.Settings.SyncDelay),
219219
"frequency": types.StringPointerValue(apiModel.Settings.Frequency),

internal/kibana/slo/schema.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ func getSchema() schema.Schema {
8282
Optional: true,
8383
ElementType: types.StringType,
8484
},
85-
"settings": schema.SingleNestedAttribute{
85+
},
86+
Blocks: map[string]schema.Block{
87+
"settings": schema.SingleNestedBlock{
8688
Description: "The default settings should be sufficient for most users, but if needed, these properties can be overwritten.",
87-
Optional: true,
88-
Computed: true,
8989
PlanModifiers: []planmodifier.Object{
9090
objectplanmodifier.UseStateForUnknown(),
9191
},
@@ -99,8 +99,6 @@ func getSchema() schema.Schema {
9999
},
100100
},
101101
},
102-
},
103-
Blocks: map[string]schema.Block{
104102
"time_window": schema.ListNestedBlock{
105103
Description: "Currently support `calendarAligned` and `rolling` time windows. Any duration greater than 1 day can be used: days, weeks, months, quarters, years. Rolling time window requires a duration, e.g. `1w` for one week, and type: `rolling`. SLOs defined with such time window, will only consider the SLI data from the last duration period as a moving window. Calendar aligned time window requires a duration, limited to `1M` for monthly or `1w` for weekly, and type: `calendarAligned`.",
106104
Validators: []validator.List{listvalidator.SizeBetween(1, 1)},

internal/kibana/slo/testdata/TestAccResourceSlo/with-data-view-id=false/apm_availability_indicator/test.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ resource "elasticstack_kibana_slo" "test_slo" {
4040

4141
space_id = "default"
4242

43-
settings = {
43+
settings {
4444
sync_delay = "5m"
4545
frequency = "5m"
4646
}

internal/kibana/slo/testdata/TestAccResourceSlo/with-data-view-id=false/histogram_custom_indicator/test.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ resource "elasticstack_kibana_slo" "test_slo" {
5353

5454
space_id = "default"
5555

56-
settings = {
56+
settings {
5757
sync_delay = "5m"
5858
frequency = "5m"
5959
}

internal/kibana/slo/testdata/TestAccResourceSlo/with-data-view-id=false/kql_custom_indicator/test.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ resource "elasticstack_kibana_slo" "test_slo" {
4646

4747
space_id = "default"
4848

49-
settings = {
49+
settings {
5050
sync_delay = "5m"
5151
frequency = "5m"
5252
}

internal/kibana/slo/testdata/TestAccResourceSlo/with-data-view-id=false/metric_custom_indicator_group_by/test.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ resource "elasticstack_kibana_slo" "test_slo" {
7171

7272
space_id = "default"
7373

74-
settings = {
74+
settings {
7575
sync_delay = "5m"
7676
frequency = "5m"
7777
}

internal/kibana/slo/testdata/TestAccResourceSlo/with-data-view-id=false/metric_custom_indicator_tags/test.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ resource "elasticstack_kibana_slo" "test_slo" {
7171

7272
space_id = "default"
7373

74-
settings = {
74+
settings {
7575
sync_delay = "5m"
7676
frequency = "5m"
7777
}

0 commit comments

Comments
 (0)