Skip to content

Latest commit

 

History

History
115 lines (77 loc) · 5.37 KB

File metadata and controls

115 lines (77 loc) · 5.37 KB
Terraform logo

Terraform Provider for OpenSearch Dashboards

The Terraform OpenSearch provider is a plugin for Terraform that allows for the full lifecycle management of OpenSearch resources. Manage Kibana saved objects, including dashboards, visualizations, and more. This provider is maintained internally by the MOIA GmbH team.

Examples

All the resources and data sources have one or more examples to give you an idea of how to use this provider to build your own OpenSearch SavedObjects infrastructure.

Development Environment Setup

Requirements

  • Terraform 0.15.0 or newer.
  • Go 1.19 (to build the provider plugin)

Opensearch version

Currently this provider is only tested with Opensearch version 1.3.6 To update the smoke-test to a new Opensearch version, changes need to be made

  • in the Makefile (env-var VERSION)
  • in the github-actions (tag of the opensearch-docker-image)

Quick Start

If you wish to work on the provider, you'll first need Go installed on your machine (please check the requirements before proceeding).

Note: This project uses Go Modules making it safe to work with it outside your existing GOPATH. The instructions that follow assume a directory in your home directory outside the standard GOPATH (i.e $HOME/development/terraform-providers/).

$ git clone [email protected]:moia-oss/terraform-provider-opensearch-dashboards.git
$ cd terraform-provider-opensearch-dashboards
...

make install will install the needed tools for the provider.

$ make install

To compile the provider, run make release. This will build the provider and put the provider binary in the ./bin directory. The provider will be compiled for different supported architectures and operation systems (check release config for supported OSs and archs). Please check your system before executing the provider locally.

$ make release
...
$ ./bin/terraform-provider-opensearch-dashboards_<version>_<os>_<arch>
...

Testing with Unit Tests

In order to run unit tests, you can run make test.

$ make test

Smoketest

This provider contains a smoketest which can test that the apply works for a few default examples against a local opensearch-instance.

Prereqesites

To run the smoketest you need a local opensearch. If you do not already have one running on your machine, follow these steps to start it:

  1. install podman or docker (and terraform if it's not already installed ;) )
  2. make sure that ports 9200, 9600 and 5601 are currently not in use
  3. run make start_opensearch (when using docker instead of podman: make start opensearch CONTAINER_RUNTIME=docker)

If you get an error like max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144] in your container logs, running sysctl -w vm.max_map_count=262144 can help (this resets after reboot so add to .bashrc or other startup-file if needed)

Running the smoketest

make smoke_test

While actively developing this plugin if you need to run the smoke_test often you can also use make smoke_test_fast but this is not as stable, so if you run into errors, fallback to make smoke_test.

Cleanup

When you finished testing and want to remove your local opensearch again, execute make remove_opensearch (or when using docker instead of podman: make remove_opensearch CONTAINER_RUNTIME=docker)

Using the Provider

To use a released provider in your Terraform environment,run terraform init and Terraform will automatically install the provider. To specify a particular provider version when installing released providers, see the Terraform documentation on provider versioning .

To instead use a custom-built provider in your Terraform environment (e.g. the provider binary from the build instructions above), follow the instructions to install it as a plugin. After placing the custom-built provider into your plugins' directory, run terraform init to initialize it.

Releasing a new provider version

The release of the provider is done automatically with a GitHub action. The workflow gets triggered if a new tag is created. Tags can be created with the GitHub web UI or the command line.

The release is signed with a GPG key that is stored as a repository secret and in terraform.

Contributing

We really appreciate your help!

To contribute, simply make a PR and a maintainer will review it shortly.

Issues on GitHub are intended to be related to the bugs or feature requests with provider codebase. See Plugin SDK Community and Discuss forum for a list of community resources to ask questions about Terraform.