Elastic has just released its official Terraform provider for configuring the Elastic Stack.
The new provider allows users to to fully control the configuration of Elasticsearch, Kibana, Fleet, and any other component within the Elastic Stack. It helps us how to safely manage production-related infrastructure using methodologies like infrastructure as code, which allow you to apply peer-reviewed infrastructure changes in an automated and controlled fashion.
Here is an example of how to spin up an Elastic Cloud deployment and how to immediately configure it with an index lifecycle policy using the new Elastic Stack Terraform Provider in a single Terraform script.
Authentication can be performed via static credentials, environment variables, or the elasticsearch_connection
block. For environment variables, ELASTICSEARCH_USERNAME
, ELASTICSEARCH_PASSWORD
, and ELASTICSEARCH_ENDPOINTS
are used to specify the username, password, and a comma-separated list of API endpoints.
Elastic also released a Terraform provider for Elastic Cloud which can be used to configure the Elasticsearch Service (ESS), Elastic Cloud Enterprise (ECE), and Elasticsearch Service Private (ESSP). For instance, the following creates an Elastic Cloud deployment of ElasticSearch and Kibana:
The ElasticSearch provider supports Elastic Stack versions from 7.x and up. It is available via GitHub and documentation is available on the Terraform registry. The Elastic Cloud provider is also available via GitHub with documentation on the Terraform registry.