Skip to content

Commit bcd1f05

Browse files
authored
Merge branch 'main' into copilot/fix-1290-2
2 parents aaacd4c + ecc0e89 commit bcd1f05

File tree

31 files changed

+1141
-297
lines changed

31 files changed

+1141
-297
lines changed

.github/workflows/test.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ jobs:
125125
- '8.14.3'
126126
- '8.15.5'
127127
- '8.16.2'
128-
- '8.17.0'
129-
- '8.18.3'
130-
- '9.0.3'
128+
- '8.17.10'
129+
- '8.18.7'
130+
- '8.19.3'
131+
- '9.0.7'
132+
- '9.1.3'
131133
steps:
132134
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
133135
- uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6

CHANGELOG.md

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

33
- Create `elasticstack_kibana_security_detection_rule` resource. ([#1290](https://github.com/elastic/terraform-provider-elasticstack/pull/1290))
4+
- Add `elasticstack_kibana_export_saved_objects` data source ([#1293](https://github.com/elastic/terraform-provider-elasticstack/pull/1293))
45
- Create `elasticstack_kibana_maintenance_window` resource. ([#1224](https://github.com/elastic/terraform-provider-elasticstack/pull/1224))
56
- Add support for `solution` field in `elasticstack_kibana_space` resource and data source ([#1102](https://github.com/elastic/terraform-provider-elasticstack/issues/1102))
67
- Add `slo_id` validation to `elasticstack_kibana_slo` ([#1221](https://github.com/elastic/terraform-provider-elasticstack/pull/1221))
@@ -14,6 +15,7 @@
1415
- Migrate `elasticstack_kibana_action_connector` to the Terraform plugin framework ([#1269](https://github.com/elastic/terraform-provider-elasticstack/pull/1269))
1516
- Migrate `elasticstack_elasticsearch_security_role_mapping` resource and data source to Terraform Plugin Framework ([#1279](https://github.com/elastic/terraform-provider-elasticstack/pull/1279))
1617
- Add support for `inactivity_timeout` in `elasticstack_fleet_agent_policy` ([#641](https://github.com/elastic/terraform-provider-elasticstack/issues/641))
18+
- Migrate `elasticstack_elasticsearch_script` resource to Terraform Plugin Framework ([#1297](https://github.com/elastic/terraform-provider-elasticstack/pull/1297))
1719
- Add support for `kafka` output types in `elasticstack_fleet_output` ([#1302](https://github.com/elastic/terraform-provider-elasticstack/pull/1302))
1820
- Add support for `prevent_initial_backfill` to `elasticstack_kibana_slo` ([#1071](https://github.com/elastic/terraform-provider-elasticstack/pull/1071))
1921
- [Refactor] Regenerate the SLO client using the current OpenAPI spec ([#1303](https://github.com/elastic/terraform-provider-elasticstack/pull/1303))

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ SWAGGER_VERSION ?= 8.7
1515

1616
GOVERSION ?= $(shell grep -e '^go' go.mod | cut -f 2 -d ' ')
1717

18-
STACK_VERSION ?= 9.0.3
18+
STACK_VERSION ?= 9.1.3
1919

2020
ELASTICSEARCH_NAME ?= terraform-elasticstack-es
2121
ELASTICSEARCH_ENDPOINTS ?= http://$(ELASTICSEARCH_NAME):9200
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
2+
---
3+
# generated by https://github.com/hashicorp/terraform-plugin-docs
4+
page_title: "elasticstack_kibana_export_saved_objects Data Source - terraform-provider-elasticstack"
5+
subcategory: "Kibana"
6+
description: |-
7+
Export Kibana saved objects. This data source allows you to export saved objects from Kibana and store the result in the Terraform state.
8+
---
9+
10+
# elasticstack_kibana_export_saved_objects (Data Source)
11+
12+
Export Kibana saved objects. This data source allows you to export saved objects from Kibana and store the result in the Terraform state.
13+
14+
## Example Usage
15+
16+
```terraform
17+
provider "elasticstack" {
18+
elasticsearch {}
19+
kibana {}
20+
}
21+
22+
data "elasticstack_kibana_export_saved_objects" "example" {
23+
exclude_export_details = true
24+
include_references_deep = true
25+
objects = [
26+
{
27+
type = "dashboard",
28+
id = "7c5f07ee-7e41-4d50-ae1f-dfe54cc87209"
29+
}
30+
]
31+
}
32+
33+
output "saved_objects" {
34+
value = data.elasticstack_kibana_export_saved_objects.example.exported_objects
35+
}
36+
```
37+
38+
<!-- schema generated by tfplugindocs -->
39+
## Schema
40+
41+
### Required
42+
43+
- `objects` (Attributes List) List of objects to export. (see [below for nested schema](#nestedatt--objects))
44+
45+
### Optional
46+
47+
- `exclude_export_details` (Boolean) Do not add export details. Defaults to true.
48+
- `include_references_deep` (Boolean) Include references to other saved objects recursively. Defaults to true.
49+
- `space_id` (String) An identifier for the space. If space_id is not provided, the default space is used.
50+
51+
### Read-Only
52+
53+
- `exported_objects` (String) The exported objects in NDJSON format.
54+
- `id` (String) Generated ID for the export.
55+
56+
<a id="nestedatt--objects"></a>
57+
### Nested Schema for `objects`
58+
59+
Required:
60+
61+
- `id` (String) The ID of the saved object.
62+
- `type` (String) The type of the saved object.

docs/resources/elasticsearch_script.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ resource "elasticstack_elasticsearch_script" "my_search_template" {
5555
### Optional
5656

5757
- `context` (String) Context in which the script or search template should run.
58-
- `elasticsearch_connection` (Block List, Max: 1, Deprecated) Elasticsearch connection configuration block. This property will be removed in a future provider version. Configure the Elasticsearch connection via the provider configuration instead. (see [below for nested schema](#nestedblock--elasticsearch_connection))
58+
- `elasticsearch_connection` (Block List, Deprecated) Elasticsearch connection configuration block. (see [below for nested schema](#nestedblock--elasticsearch_connection))
5959
- `params` (String) Parameters for the script or search template.
6060

6161
### Read-Only
6262

63-
- `id` (String) The ID of this resource.
63+
- `id` (String) Internal identifier of the resource
6464

6565
<a id="nestedblock--elasticsearch_connection"></a>
6666
### Nested Schema for `elasticsearch_connection`

docs/resources/elasticsearch_watch.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
page_title: "elasticstack_elasticsearch_watch Resource - terraform-provider-elasticstack"
55
subcategory: "Elasticsearch"
66
description: |-
7-
Manage Watches. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api.html
7+
Manage Watches. See the Watcher API documentation https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api.html for more details.
88
---
99

1010
# elasticstack_elasticsearch_watch (Resource)
1111

12-
Manage Watches. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api.html
12+
Manage Watches. See the [Watcher API documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/watcher-api.html) for more details.
1313

1414
## Example Usage
1515

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
provider "elasticstack" {
2+
elasticsearch {}
3+
kibana {}
4+
}
5+
6+
data "elasticstack_kibana_export_saved_objects" "example" {
7+
exclude_export_details = true
8+
include_references_deep = true
9+
objects = [
10+
{
11+
type = "dashboard",
12+
id = "7c5f07ee-7e41-4d50-ae1f-dfe54cc87209"
13+
}
14+
]
15+
}
16+
17+
output "saved_objects" {
18+
value = data.elasticstack_kibana_export_saved_objects.example.exported_objects
19+
}

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ require (
1111
github.com/hashicorp/go-cty v1.5.0
1212
github.com/hashicorp/go-uuid v1.0.3
1313
github.com/hashicorp/go-version v1.7.0
14-
github.com/hashicorp/terraform-plugin-framework v1.16.0
14+
github.com/hashicorp/terraform-plugin-framework v1.16.1
1515
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0
1616
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0
1717
github.com/hashicorp/terraform-plugin-go v0.29.0
1818
github.com/hashicorp/terraform-plugin-log v0.9.0
1919
github.com/hashicorp/terraform-plugin-mux v0.20.0
20-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.0
20+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1
2121
github.com/hashicorp/terraform-plugin-testing v1.13.3
2222
github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c
2323
github.com/oapi-codegen/runtime v1.1.2

go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -607,8 +607,8 @@ github.com/hashicorp/terraform-json v0.27.1 h1:zWhEracxJW6lcjt/JvximOYyc12pS/gaK
607607
github.com/hashicorp/terraform-json v0.27.1/go.mod h1:GzPLJ1PLdUG5xL6xn1OXWIjteQRT2CNT9o/6A9mi9hE=
608608
github.com/hashicorp/terraform-plugin-docs v0.22.0 h1:fwIDStbFel1PPNkM+mDPnpB4efHZBdGoMz/zt5FbTDw=
609609
github.com/hashicorp/terraform-plugin-docs v0.22.0/go.mod h1:55DJVyZ7BNK4t/lANcQ1YpemRuS6KsvIO1BbGA+xzGE=
610-
github.com/hashicorp/terraform-plugin-framework v1.16.0 h1:tP0f+yJg0Z672e7levixDe5EpWwrTrNryPM9kDMYIpE=
611-
github.com/hashicorp/terraform-plugin-framework v1.16.0/go.mod h1:0xFOxLy5lRzDTayc4dzK/FakIgBhNf/lC4499R9cV4Y=
610+
github.com/hashicorp/terraform-plugin-framework v1.16.1 h1:1+zwFm3MEqd/0K3YBB2v9u9DtyYHyEuhVOfeIXbteWA=
611+
github.com/hashicorp/terraform-plugin-framework v1.16.1/go.mod h1:0xFOxLy5lRzDTayc4dzK/FakIgBhNf/lC4499R9cV4Y=
612612
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0 h1:SJXL5FfJJm17554Kpt9jFXngdM6fXbnUnZ6iT2IeiYA=
613613
github.com/hashicorp/terraform-plugin-framework-jsontypes v0.2.0/go.mod h1:p0phD0IYhsu9bR4+6OetVvvH59I6LwjXGnTVEr8ox6E=
614614
github.com/hashicorp/terraform-plugin-framework-validators v0.18.0 h1:OQnlOt98ua//rCw+QhBbSqfW3QbwtVrcdWeQN5gI3Hw=
@@ -619,8 +619,8 @@ github.com/hashicorp/terraform-plugin-log v0.9.0 h1:i7hOA+vdAItN1/7UrfBqBwvYPQ9T
619619
github.com/hashicorp/terraform-plugin-log v0.9.0/go.mod h1:rKL8egZQ/eXSyDqzLUuwUYLVdlYeamldAHSxjUFADow=
620620
github.com/hashicorp/terraform-plugin-mux v0.20.0 h1:3QpBnI9uCuL0Yy2Rq/kR9cOdmOFNhw88A2GoZtk5aXM=
621621
github.com/hashicorp/terraform-plugin-mux v0.20.0/go.mod h1:wSIZwJjSYk86NOTX3fKUlThMT4EAV1XpBHz9SAvjQr4=
622-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.0 h1:PQP7Crrc7t/ozj+P9x0/lsTzGNy3lVppH8zAJylofaE=
623-
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.0/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU=
622+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1 h1:mlAq/OrMlg04IuJT7NpefI1wwtdpWudnEmjuQs04t/4=
623+
github.com/hashicorp/terraform-plugin-sdk/v2 v2.38.1/go.mod h1:GQhpKVvvuwzD79e8/NZ+xzj+ZpWovdPAe8nfV/skwNU=
624624
github.com/hashicorp/terraform-plugin-testing v1.13.3 h1:QLi/khB8Z0a5L54AfPrHukFpnwsGL8cwwswj4RZduCo=
625625
github.com/hashicorp/terraform-plugin-testing v1.13.3/go.mod h1:WHQ9FDdiLoneey2/QHpGM/6SAYf4A7AZazVg7230pLE=
626626
github.com/hashicorp/terraform-registry-address v0.4.0 h1:S1yCGomj30Sao4l5BMPjTGZmCNzuv7/GDTDX99E9gTk=

internal/clients/elasticsearch/cluster.go

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/elastic/terraform-provider-elasticstack/internal/clients"
1111
"github.com/elastic/terraform-provider-elasticstack/internal/diagutil"
1212
"github.com/elastic/terraform-provider-elasticstack/internal/models"
13+
fwdiag "github.com/hashicorp/terraform-plugin-framework/diag"
1314
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1415
)
1516

@@ -234,68 +235,68 @@ func GetSettings(ctx context.Context, apiClient *clients.ApiClient) (map[string]
234235
return clusterSettings, diags
235236
}
236237

237-
func GetScript(ctx context.Context, apiClient *clients.ApiClient, id string) (*models.Script, diag.Diagnostics) {
238+
func GetScript(ctx context.Context, apiClient *clients.ApiClient, id string) (*models.Script, fwdiag.Diagnostics) {
238239
esClient, err := apiClient.GetESClient()
239240
if err != nil {
240-
return nil, diag.FromErr(err)
241+
return nil, fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to get ES client", err.Error())}
241242
}
242243
res, err := esClient.GetScript(id, esClient.GetScript.WithContext(ctx))
243244
if err != nil {
244-
return nil, diag.FromErr(err)
245+
return nil, fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to get script", err.Error())}
245246
}
246247
defer res.Body.Close()
247248
if res.StatusCode == http.StatusNotFound {
248249
return nil, nil
249250
}
250-
if diags := diagutil.CheckError(res, fmt.Sprintf("Unable to get stored script: %s", id)); diags.HasError() {
251+
if diags := diagutil.CheckErrorFromFW(res, fmt.Sprintf("Unable to get stored script: %s", id)); diags.HasError() {
251252
return nil, diags
252253
}
253254
var scriptResponse struct {
254255
Script *models.Script `json:"script"`
255256
}
256257
if err := json.NewDecoder(res.Body).Decode(&scriptResponse); err != nil {
257-
return nil, diag.FromErr(err)
258+
return nil, fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to decode script response", err.Error())}
258259
}
259260

260261
return scriptResponse.Script, nil
261262
}
262263

263-
func PutScript(ctx context.Context, apiClient *clients.ApiClient, script *models.Script) diag.Diagnostics {
264+
func PutScript(ctx context.Context, apiClient *clients.ApiClient, script *models.Script) fwdiag.Diagnostics {
264265
req := struct {
265266
Script *models.Script `json:"script"`
266267
}{
267268
script,
268269
}
269270
scriptBytes, err := json.Marshal(req)
270271
if err != nil {
271-
return diag.FromErr(err)
272+
return fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to marshal script", err.Error())}
272273
}
273274
esClient, err := apiClient.GetESClient()
274275
if err != nil {
275-
return diag.FromErr(err)
276+
return fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to get ES client", err.Error())}
276277
}
277278
res, err := esClient.PutScript(script.ID, bytes.NewReader(scriptBytes), esClient.PutScript.WithContext(ctx), esClient.PutScript.WithScriptContext(script.Context))
278279
if err != nil {
279-
return diag.FromErr(err)
280+
return fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to put script", err.Error())}
280281
}
281282
defer res.Body.Close()
282-
if diags := diagutil.CheckError(res, "Unable to put stored script"); diags.HasError() {
283+
if diags := diagutil.CheckErrorFromFW(res, "Unable to put stored script"); diags.HasError() {
283284
return diags
284285
}
285286
return nil
286287
}
287288

288-
func DeleteScript(ctx context.Context, apiClient *clients.ApiClient, id string) diag.Diagnostics {
289+
func DeleteScript(ctx context.Context, apiClient *clients.ApiClient, id string) fwdiag.Diagnostics {
289290
esClient, err := apiClient.GetESClient()
290291
if err != nil {
291-
return diag.FromErr(err)
292+
return fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to get ES client", err.Error())}
292293
}
293294
res, err := esClient.DeleteScript(id, esClient.DeleteScript.WithContext(ctx))
294295
if err != nil {
295-
return diag.FromErr(err)
296+
return fwdiag.Diagnostics{fwdiag.NewErrorDiagnostic("Failed to delete script", err.Error())}
296297
}
297298
defer res.Body.Close()
298-
if diags := diagutil.CheckError(res, fmt.Sprintf("Unable to delete script: %s", id)); diags.HasError() {
299+
if diags := diagutil.CheckErrorFromFW(res, fmt.Sprintf("Unable to delete script: %s", id)); diags.HasError() {
299300
return diags
300301
}
301302
return nil

0 commit comments

Comments
 (0)