Skip to content

Commit a768e11

Browse files
authored
Merge branch 'main' into update-test-matrix
2 parents 86b15f3 + 5d14626 commit a768e11

File tree

83 files changed

+16320
-2871
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+16320
-2871
lines changed

.github/workflows/test.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ jobs:
1818
runs-on: ubuntu-latest
1919
timeout-minutes: 5
2020
steps:
21-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
22-
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
21+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
22+
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
2323
with:
2424
go-version-file: 'go.mod'
2525
cache: true
@@ -34,8 +34,8 @@ jobs:
3434
name: Lint
3535
runs-on: ubuntu-latest
3636
steps:
37-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
38-
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
37+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
38+
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
3939
with:
4040
go-version-file: 'tools/go.mod'
4141
cache: true
@@ -125,8 +125,8 @@ jobs:
125125
- '8.14.3'
126126
- '8.15.3'
127127
steps:
128-
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
129-
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5
128+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
129+
- uses: actions/setup-go@41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed # v5
130130
with:
131131
go-version-file: 'go.mod'
132132
cache: true

CHANGELOG.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
## [Unreleased]
22

3+
- Support multiple group by fields in SLOs ([#870](https://github.com/elastic/terraform-provider-elasticstack/pull/878))
4+
- Use the auto-generated OAS schema from elastic/kibana for the Fleet API. ([#834](https://github.com/elastic/terraform-provider-elasticstack/issues/834))
5+
- Support description in `elasticstack_elasticsearch_security_role` data sources. ([#884](https://github.com/elastic/terraform-provider-elasticstack/pull/884))
6+
- Prevent spurious recreation of `elasticstack_fleet_agent_policy` resources due to 'changing' policy ids ([#885](https://github.com/elastic/terraform-provider-elasticstack/pull/885))
7+
- Support `elasticstack_kibana_alerting_rule` resources with only one of `kql` or `timeframe` attributes set ([#886](https://github.com/elastic/terraform-provider-elasticstack/pull/886))
8+
9+
## [0.11.11] - 2024-10-25
10+
11+
- Allow `elasticstack_kibana_alerting_rule` to be used without Elasticsearch being configured. ([#869](https://github.com/elastic/terraform-provider-elasticstack/pull/869))
12+
- Add resource `elasticstack_elasticsearch_data_stream_lifecycle` ([#838](https://github.com/elastic/terraform-provider-elasticstack/issues/838))
13+
- Ensure API keys are not replaced when upgrading from 0.11.9 or earlier. ([#875](https://github.com/elastic/terraform-provider-elasticstack/pull/875))
14+
315
## [0.11.10] - 2024-10-23
416

517
- Fix bug updating alert delay ([#859](https://github.com/elastic/terraform-provider-elasticstack/pull/859))
@@ -376,9 +388,10 @@
376388
- Initial set of docs
377389
- CI integration
378390
379-
[Unreleased]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.10...HEAD
380-
[0.11.9]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.9...v0.11.10
381-
[0.11.8]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.8...v0.11.9
391+
[Unreleased]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.11...HEAD
392+
[0.11.11]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.9...v0.11.11
393+
[0.11.10]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.9...v0.11.10
394+
[0.11.9]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.8...v0.11.9
382395
[0.11.8]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.7...v0.11.8
383396
[0.11.7]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.6...v0.11.7
384397
[0.11.6]: https://github.com/elastic/terraform-provider-elasticstack/compare/v0.11.5...v0.11.6

Makefile

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
SHELL := /bin/bash
33

44

5-
VERSION ?= 0.11.10
5+
VERSION ?= 0.11.11
66

77
NAME = elasticstack
88
BINARY = terraform-provider-${NAME}
@@ -35,7 +35,6 @@ FLEET_NAME ?= terraform-elasticstack-fleet
3535
FLEET_ENDPOINT ?= https://$(FLEET_NAME):8220
3636

3737
SOURCE_LOCATION ?= $(shell pwd)
38-
, := ,
3938

4039
export GOBIN = $(shell pwd)/bin
4140

@@ -73,6 +72,11 @@ retry = until [ $$(if [ -z "$$attempt" ]; then echo -n "0"; else echo -n "$$atte
7372
backoff=$$((backoff * 2)); \
7473
done
7574

75+
# wait_until_healthy command - first argument is the container name
76+
wait_until_healthy = $(call retry, 5, [ "$$(docker inspect -f '{{ .State.Health.Status }}' $(1))" == "healthy" ])
77+
78+
CURL_OPTS = -sS --retry 5 --retry-all-errors -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json"
79+
7680
# To run specific test (e.g. TestAccResourceActionConnector) execute `make docker-testacc TESTARGS='-run ^TestAccResourceActionConnector$$'`
7781
# To enable tracing (or debugging), execute `make docker-testacc TF_LOG=TRACE`
7882
.PHONY: docker-testacc
@@ -107,8 +111,7 @@ docker-testacc-with-token:
107111
.PHONY: docker-elasticsearch
108112
docker-elasticsearch: docker-network ## Start Elasticsearch single node cluster in docker container
109113
@ docker rm -f $(ELASTICSEARCH_NAME) &> /dev/null || true
110-
@ $(call retry, 5, if ! docker ps --format '{{.Names}}' | grep -w $(ELASTICSEARCH_NAME) > /dev/null 2>&1 ; then \
111-
docker run -d \
114+
@ docker run -d \
112115
--memory $(ELASTICSEARCH_MEM) \
113116
-p 9200:9200 -p 9300:9300 \
114117
-e "discovery.type=single-node" \
@@ -122,14 +125,15 @@ docker-elasticsearch: docker-network ## Start Elasticsearch single node cluster
122125
-e ELASTIC_PASSWORD=$(ELASTICSEARCH_PASSWORD) \
123126
--name $(ELASTICSEARCH_NAME) \
124127
--network $(ELASTICSEARCH_NETWORK) \
125-
docker.elastic.co/elasticsearch/elasticsearch:$(STACK_VERSION); \
126-
fi)
128+
--health-cmd="curl http://localhost:9200/_cluster/health" \
129+
--health-interval=10s --health-timeout=5s --health-retries=10 \
130+
docker.elastic.co/elasticsearch/elasticsearch:$(STACK_VERSION)
131+
@ $(call wait_until_healthy, $(ELASTICSEARCH_NAME))
127132

128133
.PHONY: docker-kibana
129134
docker-kibana: docker-network docker-elasticsearch set-kibana-password ## Start Kibana node in docker container
130135
@ docker rm -f $(KIBANA_NAME) &> /dev/null || true
131-
@ $(call retry, 5, if ! docker ps --format '{{.Names}}' | grep -w $(KIBANA_NAME) > /dev/null 2>&1 ; then \
132-
docker run -d \
136+
@ docker run -d \
133137
-p 5601:5601 \
134138
-e SERVER_NAME=kibana \
135139
-e ELASTICSEARCH_HOSTS=$(ELASTICSEARCH_ENDPOINTS) \
@@ -139,18 +143,18 @@ docker-kibana: docker-network docker-elasticsearch set-kibana-password ## Start
139143
-e LOGGING_ROOT_LEVEL=debug \
140144
--name $(KIBANA_NAME) \
141145
--network $(ELASTICSEARCH_NETWORK) \
142-
docker.elastic.co/kibana/kibana:$(STACK_VERSION); \
143-
fi)
146+
--health-cmd="curl http://localhost:5601/api/status" \
147+
--health-interval=10s --health-timeout=5s --health-retries=10 \
148+
docker.elastic.co/kibana/kibana:$(STACK_VERSION)
149+
@ $(call wait_until_healthy, $(KIBANA_NAME))
144150

145151
.PHONY: docker-kibana-with-tls
146152
docker-kibana-with-tls: docker-network docker-elasticsearch set-kibana-password
147153
@ docker rm -f $(KIBANA_NAME) &> /dev/null || true
148154
@ mkdir -p certs
149155
@ CAROOT=certs mkcert localhost $(KIBANA_NAME)
150156
@ mv localhost*.pem certs/
151-
152-
@ $(call retry, 5, if ! docker ps --format '{{.Names}}' | grep -w $(KIBANA_NAME) > /dev/null 2>&1 ; then \
153-
docker run -d \
157+
@ docker run -d \
154158
-p 5601:5601 \
155159
-v $(shell pwd)/certs:/certs \
156160
-e SERVER_NAME=kibana \
@@ -164,14 +168,15 @@ docker-kibana-with-tls: docker-network docker-elasticsearch set-kibana-password
164168
-e LOGGING_ROOT_LEVEL=debug \
165169
--name $(KIBANA_NAME) \
166170
--network $(ELASTICSEARCH_NETWORK) \
167-
docker.elastic.co/kibana/kibana:$(STACK_VERSION); \
168-
fi)
171+
--health-cmd="curl -k https://localhost:5601/api/status" \
172+
--health-interval=10s --health-timeout=5s --health-retries=10 \
173+
docker.elastic.co/kibana/kibana:$(STACK_VERSION)
174+
@ $(call wait_until_healthy, $(KIBANA_NAME))
169175

170176
.PHONY: docker-fleet
171177
docker-fleet: docker-network docker-elasticsearch docker-kibana setup-kibana-fleet ## Start Fleet node in docker container
172178
@ docker rm -f $(FLEET_NAME) &> /dev/null || true
173-
@ $(call retry, 5, if ! docker ps --format '{{.Names}}' | grep -w $(FLEET_NAME) > /dev/null 2>&1 ; then \
174-
docker run -d \
179+
@ docker run -d \
175180
-p 8220:8220 \
176181
-e SERVER_NAME=fleet \
177182
-e FLEET_ENROLL=1 \
@@ -188,33 +193,30 @@ docker-fleet: docker-network docker-elasticsearch docker-kibana setup-kibana-fle
188193
-e KIBANA_FLEET_PASSWORD=$(ELASTICSEARCH_PASSWORD) \
189194
--name $(FLEET_NAME) \
190195
--network $(ELASTICSEARCH_NETWORK) \
191-
docker.elastic.co/beats/elastic-agent:$(STACK_VERSION); \
192-
fi)
196+
docker.elastic.co/beats/elastic-agent:$(STACK_VERSION)
193197

194198

195199
.PHONY: docker-network
196200
docker-network: ## Create a dedicated network for ES and test runs
197-
@ if ! docker network ls --format '{{.Name}}' | grep -w $(ELASTICSEARCH_NETWORK) > /dev/null 2>&1 ; then \
198-
docker network create $(ELASTICSEARCH_NETWORK); \
199-
fi
201+
@ docker network inspect $(ELASTICSEARCH_NETWORK) >/dev/null 2>&1 || docker network create $(ELASTICSEARCH_NETWORK)
200202

201203
.PHONY: set-kibana-password
202204
set-kibana-password: ## Sets the ES KIBANA_SYSTEM_USERNAME's password to KIBANA_SYSTEM_PASSWORD. This expects Elasticsearch to be available at localhost:9200
203-
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/user/$(KIBANA_SYSTEM_USERNAME)/_password -d '{"password":"$(KIBANA_SYSTEM_PASSWORD)"}' | grep -q "^{}")
205+
@ curl $(CURL_OPTS) http://localhost:9200/_security/user/$(KIBANA_SYSTEM_USERNAME)/_password -d '{"password":"$(KIBANA_SYSTEM_PASSWORD)"}'
204206

205207
.PHONY: create-es-api-key
206208
create-es-api-key: ## Creates and outputs a new API Key. This expects Elasticsearch to be available at localhost:9200
207-
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/api_key -d '{"name":"$(KIBANA_API_KEY_NAME)"}')
209+
@ curl $(CURL_OPTS) http://localhost:9200/_security/api_key -d '{"name":"$(KIBANA_API_KEY_NAME)"}'
208210

209211
.PHONY: create-es-bearer-token
210212
create-es-bearer-token: ## Creates and outputs a new OAuth bearer token. This expects Elasticsearch to be available at localhost:9200
211-
@ $(call retry, 10, curl -sS -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" http://localhost:9200/_security/oauth2/token -d '{"grant_type":"client_credentials"}')
213+
@ curl $(CURL_OPTS) http://localhost:9200/_security/oauth2/token -d '{"grant_type":"client_credentials"}'
212214

213215
.PHONY: setup-kibana-fleet
214216
setup-kibana-fleet: ## Creates the agent and integration policies required to run Fleet. This expects Kibana to be available at localhost:5601
215-
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/fleet_server_hosts -d '{"name":"default"$(,)"host_urls":["$(FLEET_ENDPOINT)"]$(,)"is_default":true}')
216-
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/agent_policies -d '{"id":"fleet-server"$(,)"name":"Fleet Server"$(,)"namespace":"default"$(,)"monitoring_enabled":["logs"$(,)"metrics"]}')
217-
@ $(call retry, 10, curl -sS --fail-with-body -X POST -u $(ELASTICSEARCH_USERNAME):$(ELASTICSEARCH_PASSWORD) -H "Content-Type: application/json" -H "kbn-xsrf: true" http://localhost:5601/api/fleet/package_policies -d '{"name":"fleet-server"$(,)"namespace":"default"$(,)"policy_id":"fleet-server"$(,)"enabled":true$(,)"inputs":[{"type":"fleet-server"$(,)"enabled":true$(,)"streams":[]$(,)"vars":{}}]$(,)"package":{"name":"fleet_server"$(,)"version":"1.5.0"}}')
217+
curl $(CURL_OPTS) -H "kbn-xsrf: true" http://localhost:5601/api/fleet/fleet_server_hosts -d '{"name":"default","host_urls":["$(FLEET_ENDPOINT)"],"is_default":true}'
218+
curl $(CURL_OPTS) -H "kbn-xsrf: true" http://localhost:5601/api/fleet/agent_policies -d '{"id":"fleet-server","name":"Fleet Server","namespace":"default","monitoring_enabled":["logs","metrics"]}'
219+
curl $(CURL_OPTS) -H "kbn-xsrf: true" http://localhost:5601/api/fleet/package_policies -d '{"name":"fleet-server","namespace":"default","policy_id":"fleet-server","enabled":true,"inputs":[{"type":"fleet-server","enabled":true,"streams":[],"vars":{}}],"package":{"name":"fleet_server","version":"1.5.0"}}'
218220

219221
.PHONY: docker-clean
220222
docker-clean: ## Try to remove provisioned nodes and assigned network

docs/data-sources/elasticsearch_security_role.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ output "role" {
4242

4343
- `applications` (Set of Object) A list of application privilege entries. (see [below for nested schema](#nestedatt--applications))
4444
- `cluster` (Set of String) A list of cluster privileges. These privileges define the cluster level actions that users with this role are able to execute.
45+
- `description` (String) The description of the role.
4546
- `global` (String) An object defining global privileges.
4647
- `id` (String) Internal identifier of the resource
4748
- `indices` (Set of Object) A list of indices permissions entries. (see [below for nested schema](#nestedatt--indices))
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
subcategory: "Index"
3+
layout: ""
4+
page_title: "Elasticstack: elasticstack_elasticsearch_data_stream_lifecycle Resource"
5+
description: |-
6+
Manages Lifecycle for Elasticsearch Data Streams
7+
---
8+
9+
# Resource: elasticstack_elasticsearch_data_stream
10+
11+
Configures the data stream lifecycle for the targeted data streams, see: https://www.elastic.co/guide/en/elasticsearch/reference/current/data-stream-apis.html
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "elasticstack" {
17+
elasticsearch {}
18+
}
19+
20+
// First we must have a index template created
21+
resource "elasticstack_elasticsearch_index_template" "my_data_stream_template" {
22+
name = "my_data_stream"
23+
24+
index_patterns = ["my-stream*"]
25+
26+
data_stream {}
27+
}
28+
29+
// and now we can create data stream based on the index template
30+
resource "elasticstack_elasticsearch_data_stream" "my_data_stream" {
31+
name = "my-stream"
32+
33+
// make sure that template is created before the data stream
34+
depends_on = [
35+
elasticstack_elasticsearch_index_template.my_data_stream_template
36+
]
37+
}
38+
39+
// finally we can manage lifecycle of data stream
40+
resource "elasticstack_elasticsearch_data_stream_lifecycle" "my_data_stream_lifecycle" {
41+
name = "my-stream"
42+
data_retention = "3d"
43+
44+
depends_on = [
45+
elasticstack_elasticsearch_data_stream.my_data_stream,
46+
]
47+
}
48+
49+
// or you can use wildcards to manage multiple lifecycles at once
50+
resource "elasticstack_elasticsearch_data_stream_lifecycle" "my_data_stream_lifecycle_multiple" {
51+
name = "stream-*"
52+
data_retention = "3d"
53+
}
54+
```
55+
56+
<!-- schema generated by tfplugindocs -->
57+
## Schema
58+
59+
### Required
60+
61+
- `name` (String) Name of the data stream. Supports wildcards.
62+
63+
### Optional
64+
65+
- `data_retention` (String) Every document added to this data stream will be stored at least for this time frame. When empty, every document in this data stream will be stored indefinitely
66+
- `downsampling` (Attributes List) Downsampling configuration objects, each defining an after interval representing when the backing index is meant to be downsampled and a fixed_interval representing the downsampling interval. (see [below for nested schema](#nestedatt--downsampling))
67+
- `elasticsearch_connection` (Block List, Deprecated) Elasticsearch connection configuration block. (see [below for nested schema](#nestedblock--elasticsearch_connection))
68+
- `enabled` (Boolean) Data stream lifecycle on/off.
69+
- `expand_wildcards` (String) Determines how wildcard patterns in the `indices` parameter match data streams and indices. Supports comma-separated values, such as `closed,hidden`.
70+
71+
### Read-Only
72+
73+
- `id` (String) Internal identifier of the resource.
74+
75+
<a id="nestedatt--downsampling"></a>
76+
### Nested Schema for `downsampling`
77+
78+
Required:
79+
80+
- `after` (String) Interval representing when the backing index is meant to be downsampled
81+
- `fixed_interval` (String) The interval at which to aggregate the original time series index.
82+
83+
84+
<a id="nestedblock--elasticsearch_connection"></a>
85+
### Nested Schema for `elasticsearch_connection`
86+
87+
Optional:
88+
89+
- `api_key` (String, Sensitive) API Key to use for authentication to Elasticsearch
90+
- `bearer_token` (String, Sensitive) Bearer Token to use for authentication to Elasticsearch
91+
- `ca_data` (String) PEM-encoded custom Certificate Authority certificate
92+
- `ca_file` (String) Path to a custom Certificate Authority certificate
93+
- `cert_data` (String) PEM encoded certificate for client auth
94+
- `cert_file` (String) Path to a file containing the PEM encoded certificate for client auth
95+
- `endpoints` (List of String, Sensitive) A list of endpoints where the terraform provider will point to, this must include the http(s) schema and port number.
96+
- `es_client_authentication` (String, Sensitive) ES Client Authentication field to be used with the bearer token
97+
- `insecure` (Boolean) Disable TLS certificate validation
98+
- `key_data` (String, Sensitive) PEM encoded private key for client auth
99+
- `key_file` (String) Path to a file containing the PEM encoded private key for client auth
100+
- `password` (String, Sensitive) Password to use for API authentication to Elasticsearch.
101+
- `username` (String) Username to use for API authentication to Elasticsearch.
102+
103+
## Import
104+
105+
Import is supported using the following syntax:
106+
107+
```shell
108+
terraform import elasticstack_elasticsearch_data_stream_lifecycle.my_data_stream_lifecycle <cluster_uuid>/<data_stream_name>
109+
```

docs/resources/elasticsearch_security_user.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,5 @@ Optional:
9999
Import is supported using the following syntax:
100100

101101
```shell
102-
terraform import elasticstack_elasticsearch_security_user.user <cluster_uuid>/elastic
102+
terraform import elasticstack_elasticsearch_security_user.user <cluster_uuid>/<user-name>
103103
```

docs/resources/kibana_slo.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ resource "elasticstack_kibana_slo" "custom_metric" {
208208

209209
- `apm_availability_indicator` (Block List, Max: 1) (see [below for nested schema](#nestedblock--apm_availability_indicator))
210210
- `apm_latency_indicator` (Block List, Max: 1) (see [below for nested schema](#nestedblock--apm_latency_indicator))
211-
- `group_by` (String) Optional group by field to use to generate an SLO per distinct value.
211+
- `group_by` (List of String) Optional group by fields to use to generate an SLO per distinct value.
212212
- `histogram_custom_indicator` (Block List, Max: 1) (see [below for nested schema](#nestedblock--histogram_custom_indicator))
213213
- `kql_custom_indicator` (Block List, Max: 1) (see [below for nested schema](#nestedblock--kql_custom_indicator))
214214
- `metric_custom_indicator` (Block List, Max: 1) (see [below for nested schema](#nestedblock--metric_custom_indicator))
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
terraform import elasticstack_elasticsearch_data_stream_lifecycle.my_data_stream_lifecycle <cluster_uuid>/<data_stream_name>
2+
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
provider "elasticstack" {
2+
elasticsearch {}
3+
}
4+
5+
// First we must have a index template created
6+
resource "elasticstack_elasticsearch_index_template" "my_data_stream_template" {
7+
name = "my_data_stream"
8+
9+
index_patterns = ["my-stream*"]
10+
11+
data_stream {}
12+
}
13+
14+
// and now we can create data stream based on the index template
15+
resource "elasticstack_elasticsearch_data_stream" "my_data_stream" {
16+
name = "my-stream"
17+
18+
// make sure that template is created before the data stream
19+
depends_on = [
20+
elasticstack_elasticsearch_index_template.my_data_stream_template
21+
]
22+
}
23+
24+
// finally we can manage lifecycle of data stream
25+
resource "elasticstack_elasticsearch_data_stream_lifecycle" "my_data_stream_lifecycle" {
26+
name = "my-stream"
27+
data_retention = "3d"
28+
29+
depends_on = [
30+
elasticstack_elasticsearch_data_stream.my_data_stream,
31+
]
32+
}
33+
34+
// or you can use wildcards to manage multiple lifecycles at once
35+
resource "elasticstack_elasticsearch_data_stream_lifecycle" "my_data_stream_lifecycle_multiple" {
36+
name = "stream-*"
37+
data_retention = "3d"
38+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
terraform import elasticstack_elasticsearch_security_user.user <cluster_uuid>/elastic
1+
terraform import elasticstack_elasticsearch_security_user.user <cluster_uuid>/<user-name>

0 commit comments

Comments
 (0)