This Terraform provider implements resource management for Meilisearch.
To use this provider, you must install it and provide authentication credentials:
terraform {
required_providers {
meilisearch = {
source = "pauldn-wttj/meilisearch"
version = "0.0.1"
}
}
}
provider "meilisearch" {
host = "http://localhost:7700"
api_key = "T35T-M45T3R-K3Y"
}
Alternatively, you may use environment variables MEILISEARCH_API_KEY
and / or MEILISEARCH_HOST
for authentication.
The MEILISEARCH_API_KEY
should have admin privileges since it may be used to create all kinds of resources.
meilisearch_api_key
: create and manage API keys for Meilisearch.meilisearch_index
: create and manage an index in Meilisearch.
meilisearch_api_key
: read API keys for Meilisearch.meilisearch_index
: read a Meilisearch index.
This template repository is built on the Terraform Plugin Framework.
- Terraform >= 1.0
- Go >= 1.22
- Docker and docker-compose >= 3.7 for development
- golangci-lint for development
- Clone the repository
- Enter the repository directory
- Build the provider using the Go
install
command:
go install
This provider uses Go modules. Please see the Go documentation for the most up to date information about using Go modules.
To add a new dependency github.com/author/dependency
to your Terraform provider:
go get github.com/author/dependency
go mod tidy
Then commit the changes to go.mod
and go.sum
.
If you wish to work on the provider, you'll first need Go installed on your machine (see Requirements above).
To compile the provider, run go install
. This will build the provider and put the provider binary in the $GOPATH/bin
directory.
Don't forget that if you want to use a local binary for a Terraform provider, you need to add the following block to your ~/.terraformrc
file:
provider_installation {
dev_overrides {
"terraform.io/pauldn-wttj/meilisearch" = "<replace/with/your/gopath/bin>"
}
direct {}
}
before using it in a .tf
file such as:
terraform {
required_providers {
meilisearch = {
source = "terraform.io/pauldn-wttj/meilisearch"
}
}
}
To generate or update documentation, run go generate
.
In order to run the full suite of Acceptance tests, run make testacc
.
make testacc
Tests are run against a Meilisearch Docker container to ease development (see docker_compose/
folder). The task will:
- Start a Docker container running a Meilisearch instance
- Seed data on the Meilisearch instance
- Run Terraform tests from the provider
- Clean up Docker volume
Install golangci-lint and run the linter:
golangci-lint run
Or using Docker:
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.52.2 golangci-lint run