-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from olksdr/feat/slm-policy
Add new resource to manage SLM policies
- Loading branch information
Showing
9 changed files
with
628 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "elasticstack_elasticsearch_snapshot_lifecycle Resource - terraform-provider-elasticstack" | ||
subcategory: "" | ||
description: |- | ||
Creates or updates a snapshot lifecycle policy. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html | ||
--- | ||
|
||
# elasticstack_elasticsearch_snapshot_lifecycle (Resource) | ||
|
||
Creates or updates a snapshot lifecycle policy. See, https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
provider "elasticstack" { | ||
elasticsearch {} | ||
} | ||
// create a repository for snapshots | ||
resource "elasticstack_elasticsearch_snapshot_repository" "repo" { | ||
name = "my_snap_repo" | ||
fs { | ||
location = "/tmp/snapshots" | ||
compress = true | ||
max_restore_bytes_per_sec = "20mb" | ||
} | ||
} | ||
// create a SLM policy and use the above created repository | ||
resource "elasticstack_elasticsearch_snapshot_lifecycle" "slm_policy" { | ||
name = "my_slm_policy" | ||
schedule = "0 30 1 * * ?" | ||
snapshot_name = "<daily-snap-{now/d}>" | ||
repository = elasticstack_elasticsearch_snapshot_repository.repo.name | ||
indices = ["data-*", "important"] | ||
ignore_unavailable = false | ||
include_global_state = false | ||
expire_after = "30d" | ||
min_count = 5 | ||
max_count = 50 | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- **name** (String) ID for the snapshot lifecycle policy you want to create or update. | ||
- **repository** (String) Repository used to store snapshots created by this policy. | ||
- **schedule** (String) Periodic or absolute schedule at which the policy creates snapshots. | ||
|
||
### Optional | ||
|
||
- **elasticsearch_connection** (Block List, Max: 1) Used to establish connection to Elasticsearch server. Overrides environment variables if present. (see [below for nested schema](#nestedblock--elasticsearch_connection)) | ||
- **expand_wildcards** (String) Determines how wildcard patterns in the `indices` parameter match data streams and indices. Supports comma-separated values, such as `closed,hidden`. | ||
- **expire_after** (String) Time period after which a snapshot is considered expired and eligible for deletion. | ||
- **feature_states** (Set of String) Feature states to include in the snapshot. | ||
- **id** (String) The ID of this resource. | ||
- **ignore_unavailable** (Boolean) If `false`, the snapshot fails if any data stream or index in indices is missing or closed. If `true`, the snapshot ignores missing or closed data streams and indices. | ||
- **include_global_state** (Boolean) If `true`, include the cluster state in the snapshot. | ||
- **indices** (Set of String) Comma-separated list of data streams and indices to include in the snapshot. | ||
- **max_count** (Number) Maximum number of snapshots to retain, even if the snapshots have not yet expired. | ||
- **metadata** (String) Attaches arbitrary metadata to the snapshot. | ||
- **min_count** (Number) Minimum number of snapshots to retain, even if the snapshots have expired. | ||
- **partial** (Boolean) If `false`, the entire snapshot will fail if one or more indices included in the snapshot do not have all primary shards available. | ||
- **snapshot_name** (String) Name automatically assigned to each snapshot created by the policy. | ||
|
||
<a id="nestedblock--elasticsearch_connection"></a> | ||
### Nested Schema for `elasticsearch_connection` | ||
|
||
Optional: | ||
|
||
- **endpoints** (List of String, Sensitive) A list of endpoints the Terraform provider will point to. They must include the http(s) schema and port number. | ||
- **password** (String, Sensitive) A password to use for API authentication to Elasticsearch. | ||
- **username** (String) A username to use for API authentication to Elasticsearch. | ||
|
||
## Import | ||
|
||
Import is supported using the following syntax: | ||
|
||
```shell | ||
terraform import elasticstack_elasticsearch_snapshot_lifecycle.my_policy <cluster_uuid>/<slm policy name> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
examples/resources/elasticstack_elasticsearch_snapshot_lifecycle/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import elasticstack_elasticsearch_snapshot_lifecycle.my_policy <cluster_uuid>/<slm policy name> |
31 changes: 31 additions & 0 deletions
31
examples/resources/elasticstack_elasticsearch_snapshot_lifecycle/resource.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
provider "elasticstack" { | ||
elasticsearch {} | ||
} | ||
|
||
// create a repository for snapshots | ||
resource "elasticstack_elasticsearch_snapshot_repository" "repo" { | ||
name = "my_snap_repo" | ||
|
||
fs { | ||
location = "/tmp/snapshots" | ||
compress = true | ||
max_restore_bytes_per_sec = "20mb" | ||
} | ||
} | ||
|
||
// create a SLM policy and use the above created repository | ||
resource "elasticstack_elasticsearch_snapshot_lifecycle" "slm_policy" { | ||
name = "my_slm_policy" | ||
|
||
schedule = "0 30 1 * * ?" | ||
snapshot_name = "<daily-snap-{now/d}>" | ||
repository = elasticstack_elasticsearch_snapshot_repository.repo.name | ||
|
||
indices = ["data-*", "important"] | ||
ignore_unavailable = false | ||
include_global_state = false | ||
|
||
expire_after = "30d" | ||
min_count = 5 | ||
max_count = 50 | ||
} |
1 change: 1 addition & 0 deletions
1
examples/resources/elasticstack_elasticsearch_snapshot_repository/import.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
terraform import elasticstack_elasticsearch_snapshot_repository.my_repository <cluster_uuid>/<repository name> |
Oops, something went wrong.