Skip to content

Commit

Permalink
Add multi-tenancy support
Browse files Browse the repository at this point in the history
Signed-off-by: Philipp Reinke <[email protected]>
  • Loading branch information
PhilippReinke committed Apr 29, 2024
1 parent 332430d commit 6b9bed5
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 187 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [Copyright](#copyright)

## Terraform Provider OpenSearch

This is a terraform provider to provision OpenSearch resources.

### Supported Functionalities
Expand All @@ -35,7 +36,6 @@ Examples of resources can be found in the examples directory.
- [x] [Alerting Monitors](https://opensearch.org/docs/latest/observing-your-data/alerting/monitors/)
- [x] [Notification Channels](https://opensearch.org/docs/latest/observing-your-data/notifications/index/)


### Running tests locally

```sh
Expand All @@ -47,9 +47,11 @@ export OPENSEARCH_URL=http://admin:admin@localhost:9200
export TF_LOG=INFO
TF_ACC=1 go test ./... -v -parallel 20 -cover -short
```

Note: 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`

#### To Run Specific Test

```sh
cd provider/
TF_ACC=2 go test -run TestAccOpensearchOpenDistroDashboardTenant -v -cover -short
Expand All @@ -61,7 +63,6 @@ TF_ACC=2 go test -run TestAccOpensearchOpenDistroDashboardTenant -v -cover -sho
golangci-lint run --out-format=github-actions
```


### Debugging this provider

Build the executable, and start in debug mode:
Expand All @@ -86,13 +87,16 @@ $ terraform apply
The local provider will be used instead, and you should see debug information printed to the terminal.

## Version and Branching

As of now, this terraform-provider-opensearch repository maintains 2 branches:
* _main_ (2.x.x OpenSearch development)
* _1.x_ (1.x.x OpenSearch development)

- _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 label `backport 1.x`, etc.

- 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 label `backport 1.x`, etc.

## Contributing

Expand Down
15 changes: 10 additions & 5 deletions docs/resources/dashboard_object.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Provides an OpenSearch Dashboards object resource. This resource interacts direc

```terraform
resource "opensearch_dashboard_object" "test_visualization_v6" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "visualization:response-time-percentile",
Expand All @@ -36,7 +37,8 @@ EOF
resource "opensearch_dashboard_object" "test_visualization_v7" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "response-time-percentile",
Expand All @@ -56,7 +58,8 @@ EOF
}
resource "opensearch_dashboard_object" "test_index_pattern_v6" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "index-pattern:cloudwatch",
Expand All @@ -74,7 +77,8 @@ EOF
}
resource "opensearch_dashboard_object" "test_index_pattern_v7" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "index-pattern:cloudwatch",
Expand All @@ -101,7 +105,8 @@ EOF

### Optional

- `index` (String) The name of the index where dashboard data is stored.
- `index` (String) The name of the index where dashboard data is stored. Does not work with tenant_name.
- `tenant_name` (String) The name of the tenant to which dashboard data associate. Empty string defaults to global tenant.

### Read-Only

Expand Down
12 changes: 8 additions & 4 deletions examples/resources/opensearch_dashboard_object/resource.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

resource "opensearch_dashboard_object" "test_visualization_v6" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "visualization:response-time-percentile",
Expand All @@ -22,7 +23,8 @@ EOF


resource "opensearch_dashboard_object" "test_visualization_v7" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "response-time-percentile",
Expand All @@ -42,7 +44,8 @@ EOF
}

resource "opensearch_dashboard_object" "test_index_pattern_v6" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "index-pattern:cloudwatch",
Expand All @@ -60,7 +63,8 @@ EOF
}

resource "opensearch_dashboard_object" "test_index_pattern_v7" {
body = <<EOF
tenant_name = "tenant"
body = <<EOF
[
{
"_id": "index-pattern:cloudwatch",
Expand Down
Loading

0 comments on commit 6b9bed5

Please sign in to comment.