An elasticsearch provider for terraform
This is a terraform provider that lets you provision elasticsearch resources, compatible with v5, v6 and v7 of elasticsearch. Based off of an original PR to Terraform.
This package is published on the official Terraform registry.
Or download a binary, and put it in a good spot on your system. Then update your
~/.terraformrcto refer to the binary:
providers { elasticsearch = "/path/to/terraform-provider-elasticsearch" }
See the docs for more on manual installation.
provider "elasticsearch" { url = "https://search-foo-bar-pqrhr4w3u4dzervg41frow4mmy.us-east-1.es.amazonaws.com" # Don't include port at the end for aws aws_access_key = "" aws_secret_key = "" aws_token = "" # if necessary insecure = true # to bypass certificate check cacert_file = "/path/to/ca.crt" # when connecting to elastic with self-signed certificate sign_aws_requests = true # only needs to be true if your domain access policy includes IAM users or roles }
Examples of resources can be found in the examples directory. The resources currently supported from the: opensource Elasticsearch, XPack and OpenDistro distributions are described below.
resource "elasticsearch_index_template" "test" { name = "terraform-test" body = <Example watches (target notification actions must be setup manually before hand)
# Monitor cluster status with auth being required resource "elasticsearch_xpack_watch" "cluster-status-red" { watch_id = "cluster-status-red" body = < node.jvm.mem.heap_used_percent > 75)" } }, "actions": { "notify-slack": { "throttle_period_in_millis": 600000, "slack": { "account": "monitoring", "message": { "from": "watcher", "to": [ "#my-slack-channel" ], "text": "Elasticsearch Monitoring", "attachments": [ { "color": "danger", "title": "JVM Memory Pressure Warning", "text": "JVM Memory Pressure has been > 75% on one or more nodes for the last 5 minutes." } ] } } } }, "metadata": { "xpack": { "type": "json" }, "name": "JVM Memory Pressure Warning" } } EOF }For use with AWS Elasticsearch domains
Please see the documentation for details.
Development
Requirements
go build -o /path/to/binary/terraform-provider-elasticsearch
See LICENSE.
git checkout -b my-new-feature)
git commit -am 'Add some feature')
git push origin my-new-feature)