Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for transforms #284

Merged
merged 27 commits into from
Mar 19, 2023
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
0858720
initial commit
Cristigeo Mar 6, 2023
8985ad1
support for Update
Cristigeo Mar 6, 2023
0c72f4a
adding missing properties for transform
Cristigeo Mar 6, 2023
91e5a0b
misc corrections
Cristigeo Mar 6, 2023
abb261b
some documentation
Cristigeo Mar 7, 2023
2f32dc8
support for transform start/stop
Cristigeo Mar 7, 2023
df3201b
addiong options on the client calls for transform start/stop
Cristigeo Mar 7, 2023
7840c93
initial commit
Cristigeo Mar 6, 2023
de26951
support for Update
Cristigeo Mar 6, 2023
db04052
adding missing properties for transform
Cristigeo Mar 6, 2023
b9d0a87
misc corrections
Cristigeo Mar 6, 2023
a19faaf
some documentation
Cristigeo Mar 7, 2023
8c2fb9a
support for transform start/stop
Cristigeo Mar 7, 2023
603e586
addiong options on the client calls for transform start/stop
Cristigeo Mar 7, 2023
b17dcae
Merge branch '49-support-for-transforms' of https://github.com/Cristi…
Cristigeo Mar 9, 2023
1d9aa97
code updates based on feedback
Cristigeo Mar 9, 2023
2f3b5e8
updated documentation (added md template)
Cristigeo Mar 9, 2023
e497cd9
timeout query param is only available from v7.17.0
Cristigeo Mar 9, 2023
c040977
fixed the messed up md file
Cristigeo Mar 9, 2023
8fc867c
settings promoted to individual arguments; drift detection for updata…
Cristigeo Mar 11, 2023
1b5db02
check versions before using features
Cristigeo Mar 12, 2023
a00822c
updated doc
Cristigeo Mar 12, 2023
4f4eb56
support for terraform import
Cristigeo Mar 12, 2023
e2ebb79
minor corrections/updates
Cristigeo Mar 14, 2023
b900984
corrected min version for align_checkpoints
Cristigeo Mar 14, 2023
0bedc94
updates on acc tests
Cristigeo Mar 14, 2023
3f447ea
removed some defaults; updated docs; updated acc test
Cristigeo Mar 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
}
```
- Add support for managing Kibana spaces ([#272](https://github.com/elastic/terraform-provider-elasticstack/pull/272))
- Add support for managing Elasticsearch transforms ([#284](https://github.com/elastic/terraform-provider-elasticstack/pull/284))

### Fixed
- Respect `ignore_unavailable` and `include_global_state` values when configuring SLM policies ([#224](https://github.com/elastic/terraform-provider-elasticstack/pull/224))
Expand Down
168 changes: 168 additions & 0 deletions docs/resources/elasticsearch_transform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
---
subcategory: "Transform"
layout: ""
page_title: "Elasticstack: elasticstack_elasticsearch_transform Resource"
description: |-
Manages transforms. Transforms enable you to convert existing Elasticsearch indices into summarized indices.
---

# Resource: elasticstack_elasticsearch_transform

Creates, updates, starts and stops a transform. See: https://www.elastic.co/guide/en/elasticsearch/reference/current/transforms.html

## Example Usage

```terraform
resource "elasticstack_elasticsearch_transform" "transform_with_pivot" {
name = "transform-pivot"
description = "A meaningful description"

source {
indices = ["names_or_patterns_for_input_index"]
}

destination {
index = "destination_index_for_transform"
}

pivot = jsonencode({
"group_by" : {
"customer_id" : {
"terms" : {
"field" : "customer_id",
"missing_bucket" : true
}
}
},
"aggregations" : {
"max_price" : {
"max" : {
"field" : "taxful_total_price"
}
}
}
})

frequency = "5m"

retention_policy {
time {
field = "order_date"
max_age = "30d"
}
}

sync {
time {
field = "order_date"
delay = "10s"
}
}

max_page_search_size = 2000

enabled = false
defer_validation = false
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `destination` (Block List, Min: 1, Max: 1) The destination for the transform. (see [below for nested schema](#nestedblock--destination))
- `name` (String) Name of the transform you wish to create.
- `source` (Block List, Min: 1, Max: 1) The source of the data for the transform. (see [below for nested schema](#nestedblock--source))

### Optional

- `align_checkpoints` (Boolean) Specifies whether the transform checkpoint ranges should be optimized for performance.
- `dates_as_epoch_millis` (Boolean) Defines if dates in the output should be written as ISO formatted string (default) or as millis since epoch.
- `deduce_mappings` (Boolean) Specifies whether the transform should deduce the destination index mappings from the transform config.
- `defer_validation` (Boolean) When true, deferrable validations are not run upon creation, but rather when the transform is started. This behavior may be desired if the source index does not exist until after the transform is created.
- `description` (String) Free text description of the transform.
- `docs_per_second` (Number) Specifies a limit on the number of input documents per second. Default (unset) value disables throttling.
- `enabled` (Boolean) Controls wether the transform should be started or stopped. Default is `false` (stopped).
- `frequency` (String) The interval between checks for changes in the source indices when the transform is running continuously. Defaults to `1m`.
- `latest` (String) The latest method transforms the data by finding the latest document for each unique key. JSON definition expected. Either 'pivot' or 'latest' must be present.
- `max_page_search_size` (Number) Defines the initial page size to use for the composite aggregation for each checkpoint. Default is 500.
- `metadata` (String) Defines optional transform metadata.
- `num_failure_retries` (Number) Defines the number of retries on a recoverable failure before the transform task is marked as failed. The default value is the cluster-level setting num_transform_failure_retries.
- `pivot` (String) The pivot method transforms the data by aggregating and grouping it. JSON definition expected. Either 'pivot' or 'latest' must be present.
- `retention_policy` (Block List, Max: 1) Defines a retention policy for the transform. (see [below for nested schema](#nestedblock--retention_policy))
- `sync` (Block List, Max: 1) Defines the properties transforms require to run continuously. (see [below for nested schema](#nestedblock--sync))
- `timeout` (String) Period to wait for a response from Elastisearch when performing any management operation. If no response is received before the timeout expires, the operation fails and returns an error. Defaults to `30s`.
- `unattended` (Boolean) In unattended mode, the transform retries indefinitely in case of an error which means the transform never fails.

### Read-Only

- `id` (String) Internal identifier of the resource

<a id="nestedblock--destination"></a>
### Nested Schema for `destination`

Required:

- `index` (String) The destination index for the transform.

Optional:

- `pipeline` (String) The unique identifier for an ingest pipeline.


<a id="nestedblock--source"></a>
### Nested Schema for `source`

Required:

- `indices` (List of String) The source indices for the transform.

Optional:

- `query` (String) A query clause that retrieves a subset of data from the source index.
- `runtime_mappings` (String) Definitions of search-time runtime fields that can be used by the transform.


<a id="nestedblock--retention_policy"></a>
### Nested Schema for `retention_policy`

Required:

- `time` (Block List, Min: 1, Max: 1) Specifies that the transform uses a time field to set the retention policy. This is currently the only supported option. (see [below for nested schema](#nestedblock--retention_policy--time))

<a id="nestedblock--retention_policy--time"></a>
### Nested Schema for `retention_policy.time`

Required:

- `field` (String) The date field that is used to calculate the age of the document.
- `max_age` (String) Specifies the maximum age of a document in the destination index.



<a id="nestedblock--sync"></a>
### Nested Schema for `sync`

Required:

- `time` (Block List, Min: 1, Max: 1) Specifies that the transform uses a time field to synchronize the source and destination indices. This is currently the only supported option. (see [below for nested schema](#nestedblock--sync--time))

<a id="nestedblock--sync--time"></a>
### Nested Schema for `sync.time`

Required:

- `field` (String) The date field that is used to identify new documents in the source.

Optional:

- `delay` (String) The time delay between the current time and the latest input data time. The default value is 60s.

## Import

Import is supported using the following syntax:

```shell
terraform import elasticstack_elasticsearch_tranform.my_new_transform <cluster_uuid>/<transform_name>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import elasticstack_elasticsearch_tranform.my_new_transform <cluster_uuid>/<transform_name>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
resource "elasticstack_elasticsearch_transform" "transform_with_pivot" {
name = "transform-pivot"
description = "A meaningful description"

source {
indices = ["names_or_patterns_for_input_index"]
}

destination {
index = "destination_index_for_transform"
}

pivot = jsonencode({
"group_by" : {
"customer_id" : {
"terms" : {
"field" : "customer_id",
"missing_bucket" : true
}
}
},
"aggregations" : {
"max_price" : {
"max" : {
"field" : "taxful_total_price"
}
}
}
})

frequency = "5m"

retention_policy {
time {
field = "order_date"
max_age = "30d"
}
}

sync {
time {
field = "order_date"
delay = "10s"
}
}

max_page_search_size = 2000

enabled = false
defer_validation = false
}
Loading