diff --git a/CHANGELOG.md b/CHANGELOG.md index dec0dd9ba..6e94645aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - Fix issue when setting `override` in `elasticstack_kibana_data_view` resource ([#550](https://github.com/elastic/terraform-provider-elasticstack/pull/550)) - Fixup typos in `elasticstack_elasticsearch_transform` and `elasticstack_kibana_security_role` docs ([#551](https://github.com/elastic/terraform-provider-elasticstack/pull/551)) - Fix issue when setting `field_attrs` in `elasticstack_kibana_data_view` resource ([#552](https://github.com/elastic/terraform-provider-elasticstack/pull/552)) +- Add an example resource and import command to the `elasticstack_kibana_data_view` docs ([#560](https://github.com/elastic/terraform-provider-elasticstack/pull/560)) ## [0.11.0] - 2023-12-12 diff --git a/docs/resources/kibana_data_view.md b/docs/resources/kibana_data_view.md index f0342d1c4..cc5d832fa 100644 --- a/docs/resources/kibana_data_view.md +++ b/docs/resources/kibana_data_view.md @@ -1,16 +1,32 @@ --- -# generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "elasticstack_kibana_data_view Resource - terraform-provider-elasticstack" -subcategory: "" +subcategory: "Kibana" +layout: "" +page_title: "Elasticstack: elasticstack_kibana_data_view Resource" description: |- - Manages Kibana data views + Manages Kibana data views. --- -# elasticstack_kibana_data_view (Resource) +# Resource: elasticstack_kibana_data_view -Manages Kibana data views +Creates and manages Kibana [data views](https://www.elastic.co/guide/en/kibana/current/data-views-api.html) +## Example Usage +```terraform +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_kibana_data_view" "my_data_view" { + data_view = { + name = "logs-*" + title = "logs-*" + time_field_name = "@timestamp" + namespaces = ["backend"] + } +} +``` ## Schema @@ -80,3 +96,11 @@ Required: - `script_source` (String) Script of the runtime field. - `type` (String) Mapping type of the runtime field. For more information, check [Field data types](https://www.elastic.co/guide/en/elasticsearch/reference/8.11/mapping-types.html). + +## Import + +Import is supported using the following syntax: + +```shell +terraform import elasticstack_kibana_data_view.my_data_view / +``` diff --git a/examples/resources/elasticstack_kibana_data_view/import.sh b/examples/resources/elasticstack_kibana_data_view/import.sh new file mode 100644 index 000000000..25b0a113e --- /dev/null +++ b/examples/resources/elasticstack_kibana_data_view/import.sh @@ -0,0 +1 @@ +terraform import elasticstack_kibana_data_view.my_data_view / diff --git a/examples/resources/elasticstack_kibana_data_view/resource.tf b/examples/resources/elasticstack_kibana_data_view/resource.tf new file mode 100644 index 000000000..81a77987d --- /dev/null +++ b/examples/resources/elasticstack_kibana_data_view/resource.tf @@ -0,0 +1,13 @@ +provider "elasticstack" { + elasticsearch {} + kibana {} +} + +resource "elasticstack_kibana_data_view" "my_data_view" { + data_view = { + name = "logs-*" + title = "logs-*" + time_field_name = "@timestamp" + namespaces = ["backend"] + } +} diff --git a/templates/resources/kibana_data_view.md.tmpl b/templates/resources/kibana_data_view.md.tmpl new file mode 100644 index 000000000..56de1c423 --- /dev/null +++ b/templates/resources/kibana_data_view.md.tmpl @@ -0,0 +1,23 @@ +--- +subcategory: "Kibana" +layout: "" +page_title: "Elasticstack: elasticstack_kibana_data_view Resource" +description: |- + Manages Kibana data views. +--- + +# Resource: elasticstack_kibana_data_view + +Creates and manages Kibana [data views](https://www.elastic.co/guide/en/kibana/current/data-views-api.html) + +## Example Usage + +{{ tffile "examples/resources/elasticstack_kibana_data_view/resource.tf" }} + +{{ .SchemaMarkdown | trimspace }} + +## Import + +Import is supported using the following syntax: + +{{ codefile "shell" "examples/resources/elasticstack_kibana_data_view/import.sh" }}