|
| 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 | +
|
| 21 | +// First we must have a index template created |
| 22 | +resource "elasticstack_elasticsearch_index_template" "my_data_stream_template" { |
| 23 | + name = "my_data_stream" |
| 24 | +
|
| 25 | + index_patterns = ["my-stream*"] |
| 26 | +
|
| 27 | + data_stream {} |
| 28 | +} |
| 29 | +
|
| 30 | +// and now we can create data stream based on the index template |
| 31 | +resource "elasticstack_elasticsearch_data_stream" "my_data_stream" { |
| 32 | + name = "my-stream" |
| 33 | +
|
| 34 | + // make sure that template is created before the data stream |
| 35 | + depends_on = [ |
| 36 | + elasticstack_elasticsearch_index_template.my_data_stream_template |
| 37 | + ] |
| 38 | +} |
| 39 | +
|
| 40 | +// finally we can manage lifecycle of data stream |
| 41 | +resource "elasticstack_elasticsearch_data_stream_lifecycle" "my_data_stream_lifecycle" { |
| 42 | + name = "my-stream" |
| 43 | + data_retention = "3d" |
| 44 | +
|
| 45 | + depends_on = [ |
| 46 | + elasticstack_elasticsearch_data_stream.my_data_stream, |
| 47 | + ] |
| 48 | +} |
| 49 | +
|
| 50 | +// or you can use wildcards to manage multiple lifecycles at once |
| 51 | +resource "elasticstack_elasticsearch_data_stream_lifecycle" "my_data_stream_lifecycle_multiple" { |
| 52 | + name = "stream-*" |
| 53 | + data_retention = "3d" |
| 54 | +} |
| 55 | +``` |
| 56 | + |
| 57 | +<!-- schema generated by tfplugindocs --> |
| 58 | + |
| 59 | +## Schema |
| 60 | + |
| 61 | +### Required |
| 62 | + |
| 63 | +- `name` (String) Name of the data stream. Supports wildcards (_). To target all data streams use _ or \_all. |
| 64 | + |
| 65 | +### Optional |
| 66 | + |
| 67 | +- `data_retention` (String) If defined, every document added to this data stream will be stored at least for this time frame. Any time after this duration the document could be deleted. When empty, every document in this data stream will be stored indefinitely |
| 68 | +- `downsampling` (Block List) An optional array of downsampling configuration objects, each defining an after interval representing when the backing index is meant to be downsampled (the time frame is calculated since the index was rolled over, i.e. generation time) and a fixed_interval representing the downsampling interval (the minimum fixed_interval value is 5m). A maximum number of 10 downsampling rounds can be configured (see [below for nested schema](#nestedblock--downsampling)) |
| 69 | +- `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)) |
| 70 | +- `enabled` (Boolean) If defined, it turns data stream lifecycle on/off (true/false) for this data stream. A data stream lifecycle that is disabled (enabled: false) will have no effect on the data stream. Defaults to true. |
| 71 | +- `expand_wildcards` (String) Type of data stream that wildcard patterns can match. Supports comma-separated values, such as open,hidden. Valid values are: |
| 72 | + |
| 73 | + all, hidden - Match any data stream, including hidden ones. |
| 74 | + open, closed - Matches any non-hidden data stream. Data streams cannot be closed. |
| 75 | + none - Wildcard patterns are not accepted. |
| 76 | + |
| 77 | + Defaults to open. |
| 78 | + |
| 79 | +### Read-Only |
| 80 | + |
| 81 | +- `id` (String) Internal identifier of the resource |
| 82 | +- `lifecycles` (List of Object) (see [below for nested schema](#nestedatt--lifecycles)) |
| 83 | + |
| 84 | +<a id="nestedblock--downsampling"></a> |
| 85 | + |
| 86 | +### Nested Schema for `downsampling` |
| 87 | + |
| 88 | +Required: |
| 89 | + |
| 90 | +- `after` (String) Interval representing when the backing index is meant to be downsampled |
| 91 | +- `fixed_interval` (String) The interval at which to aggregate the original time series index. For example, 60m produces a document for each 60 minute (hourly) interval. This follows standard time formatting syntax as used elsewhere in Elasticsearch. |
| 92 | + |
| 93 | +<a id="nestedblock--elasticsearch_connection"></a> |
| 94 | + |
| 95 | +### Nested Schema for `elasticsearch_connection` |
| 96 | + |
| 97 | +Optional: |
| 98 | + |
| 99 | +- `api_key` (String, Sensitive) API Key to use for authentication to Elasticsearch |
| 100 | +- `bearer_token` (String, Sensitive) Bearer Token to use for authentication to Elasticsearch |
| 101 | +- `ca_data` (String) PEM-encoded custom Certificate Authority certificate |
| 102 | +- `ca_file` (String) Path to a custom Certificate Authority certificate |
| 103 | +- `cert_data` (String) PEM encoded certificate for client auth |
| 104 | +- `cert_file` (String) Path to a file containing the PEM encoded certificate for client auth |
| 105 | +- `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. |
| 106 | +- `es_client_authentication` (String, Sensitive) ES Client Authentication field to be used with the bearer token |
| 107 | +- `insecure` (Boolean) Disable TLS certificate validation |
| 108 | +- `key_data` (String, Sensitive) PEM encoded private key for client auth |
| 109 | +- `key_file` (String) Path to a file containing the PEM encoded private key for client auth |
| 110 | +- `password` (String, Sensitive) Password to use for API authentication to Elasticsearch. |
| 111 | +- `username` (String) Username to use for API authentication to Elasticsearch. |
| 112 | + |
| 113 | +<a id="nestedatt--lifecycles"></a> |
| 114 | + |
| 115 | +### Nested Schema for `lifecycles` |
| 116 | + |
| 117 | +Read-Only: |
| 118 | + |
| 119 | +- `data_retention` (String) |
| 120 | +- `downsampling` (List of Object) (see [below for nested schema](#nestedobjatt--lifecycles--downsampling)) |
| 121 | +- `enabled` (Boolean) |
| 122 | +- `name` (String) |
| 123 | + |
| 124 | +<a id="nestedobjatt--lifecycles--downsampling"></a> |
| 125 | + |
| 126 | +### Nested Schema for `lifecycles.downsampling` |
| 127 | + |
| 128 | +Read-Only: |
| 129 | + |
| 130 | +- `after` (String) |
| 131 | +- `fixed_interval` (String) |
0 commit comments