- Terraform Provider OpenSearch
- Version and Branching
- Contributing
- Getting Help
- Code of Conduct
- Security
- License
- Copyright
This is a terraform provider to provision OpenSearch resources.
Examples of resources can be found in the examples directory.
- Cluster Settings
- Audit Config
- Component templates
- Index and Composable templates
- Data Streams
- Ingest Pipeline
- Security
- Snapshot Repository
- Anomaly Detection
- Index State Management
- Dashboards Visualization
- Dashboards Tenant
- Alerting Monitors
- Notification Channels
- ML Commons
The Makefile wraps the most common workflows. Running make test starts a local OpenSearch cluster (via Docker Compose) and executes the full acceptance-test suite:
make testManual equivalent (no make):
export OSS_IMAGE="opensearchproject/opensearch:2"
docker compose up -d
docker compose ps -a # Checks that the process is running
# Before OS 2.12.0
# export OPENSEARCH_URL=http://admin:admin@localhost:9200
export OPENSEARCH_URL=http://admin:myStrongPassword123%40456@localhost:9200
export TF_LOG=INFO
TF_ACC=1 go test ./... -v -parallel 20 -cover -shortNote: Starting from version 2.12.0, the admin user password is determined by the OPENSEARCH_INITIAL_ADMIN_PASSWORD environment variable. If testing against a cluster with version 2.12.0 or later and have set OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123@456, please update the URL as follows: export OPENSEARCH_URL=http://admin:myStrongPassword123%40456@localhost:9200
cd provider/
TF_ACC=2 go test -run TestAccOpensearchOpenDistroDashboardTenant -v -cover -shortgolangci-lint run --out-format=github-actionsThe dev/ directory is a ready-to-use Terraform configuration that provisions a small set of resources against a locally-running cluster.
It is useful for iterating on provider changes end-to-end without writing temporary Terraform code.
One-command setup (starts OpenSearch + Dashboards, builds the provider, and applies the sandbox config):
make devThe images for OpenSearch core and OpenSearch Dashboards can be overridden; so can the initial admin password:
OSS_IMAGE=opensearchproject/opensearch:2.17.0 \
OSS_DASHBOARDS_IMAGE=opensearchproject/opensearch-dashboards:2.17.0 \
OPENSEARCH_INITIAL_ADMIN_PASSWORD=myStrongPassword123@456 \
make dev-upTo manage the cluster independently (without Dashboards):
make up # start OpenSearch only
make down # stop OpenSearchAvailable Make targets related to the development sandbox:
| Target | Description |
|---|---|
make dev-up |
Start OpenSearch + OpenSearch Dashboards (dashboards Compose profile) |
make dev-build |
Build the provider binary to use locally |
make dev-config |
Generate .dev.terraformrc with a dev_overrides block pointing to the local binary |
make dev-plan |
Build + terraform plan against dev/ |
make dev-apply |
Build + terraform apply -auto-approve against dev/ |
make dev-destroy |
terraform destroy -auto-approve (cluster stays up) |
make dev-teardown |
Destroy Terraform resources and stop the OpenSearch cluster + OpenSearch Dashboards |
make dev-down |
Stop OpenSearch cluster + OpenSearch Dashboards without touching Terraform state |
Terraform variables are read from dev/terraform.tfvars (gitignored). Copy dev/terraform.tfvars.example to get started.
The defaults work against the local Docker cluster with no changes needed.
For AWS-specific testing, pass credentials as TF_VAR_* environment variables — see dev/terraform.tfvars.example.
The UI of OpenSearch Dashboards will be exposed at http://localhost:5601 when the dev-up target is used.
Generate example usage documentation in docs/ from the configuration in resources/<resource name>/import.sh and
resources/<resource name>/resource.tf:
make docsBuild the executable, and start in debug mode:
$ go build
$ ./terraform-provider-opensearch -debuggable # or start in debug mode in your IDE
{"@level":"debug","@message":"plugin address","@timestamp":"2022-05-17T10:10:04.331668+01:00","address":"/var/folders/32/3mbbgs9x0r5bf991ltrl3p280010fs/T/plugin1346340234","network":"unix"}
Provider started, to attach Terraform set the TF_REATTACH_PROVIDERS env var:
TF_REATTACH_PROVIDERS='{"registry.terraform.io/opensearch-project/opensearch":{"Protocol":"grpc","ProtocolVersion":5,"Pid":79075,"Test":true,"Addr":{"Network":"unix","String":"/var/folders/32/3mbbgs9x0r5bf991ltrl3p280010fs/T/plugin1346340234"}}}'In another terminal, you can test your terraform code:
$ cd <my-project/terraform>
$ export TF_REATTACH_PROVIDERS=<env var above>
$ terraform applyThe local provider will be used instead, and you should see debug information printed to the terminal.
As of now, this terraform-provider-opensearch repository maintains 2 branches:
- main (2.x.x OpenSearch development)
- 1.x (1.x.x OpenSearch development)
Contributors should choose the corresponding branch(es) when commiting their change(s):
- If you have a change for a specific version, only open PR to specific branch
- If you have a change for all available versions, first open a PR on
main, then open a backport PR with[x]in the title, with labelbackport 1.x, etc.
See developer guide and how to contribute to this project.
If you find a bug, or have a feature request, please don't hesitate to open an issue in this repository.
For more information, see project website and documentation. If you need help and are unsure where to open an issue, try forums.
This project has adopted the Amazon Open Source Code of Conduct. For more information see the Code of Conduct FAQ, or contact opensource-codeofconduct@amazon.com with any additional questions or comments.
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our vulnerability reporting page. Please do not create a public GitHub issue.
This project is licensed under the Apache v2.0 License.
Copyright OpenSearch Contributors. See NOTICE for details.