Skip to content

Commit bdfb6d1

Browse files
Add multi-tenancy support (#184)
* Add multi-tenancy support Signed-off-by: Philipp Reinke <[email protected]> * Rename dashboardSavedObjectMeta to kibanaSavedObjectMeta Signed-off-by: Philipp Reinke <[email protected]> --------- Signed-off-by: Philipp Reinke <[email protected]>
1 parent 1117260 commit bdfb6d1

File tree

6 files changed

+316
-188
lines changed

6 files changed

+316
-188
lines changed

README.md

+10-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Copyright](#copyright)
1313

1414
## Terraform Provider OpenSearch
15+
1516
This is a terraform provider to provision OpenSearch resources.
1617

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

38-
3939
### Running tests locally
4040

4141
```sh
@@ -47,9 +47,11 @@ export OPENSEARCH_URL=http://admin:admin@localhost:9200
4747
export TF_LOG=INFO
4848
TF_ACC=1 go test ./... -v -parallel 20 -cover -short
4949
```
50+
5051
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`
5152

5253
#### To Run Specific Test
54+
5355
```sh
5456
cd provider/
5557
TF_ACC=2 go test -run TestAccOpensearchOpenDistroDashboardTenant -v -cover -short
@@ -61,7 +63,6 @@ TF_ACC=2 go test -run TestAccOpensearchOpenDistroDashboardTenant -v -cover -sho
6163
golangci-lint run --out-format=github-actions
6264
```
6365

64-
6566
### Debugging this provider
6667

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

8889
## Version and Branching
90+
8991
As of now, this terraform-provider-opensearch repository maintains 2 branches:
90-
* _main_ (2.x.x OpenSearch development)
91-
* _1.x_ (1.x.x OpenSearch development)
92+
93+
- _main_ (2.x.x OpenSearch development)
94+
- _1.x_ (1.x.x OpenSearch development)
9295

9396
Contributors should choose the corresponding branch(es) when commiting their change(s):
94-
* If you have a change for a specific version, only open PR to specific branch
95-
* 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.
97+
98+
- If you have a change for a specific version, only open PR to specific branch
99+
- 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.
96100

97101
## Contributing
98102

docs/resources/dashboard_object.md

+10-5
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ Provides an OpenSearch Dashboards object resource. This resource interacts direc
1414

1515
```terraform
1616
resource "opensearch_dashboard_object" "test_visualization_v6" {
17-
body = <<EOF
17+
tenant_name = "tenant"
18+
body = <<EOF
1819
[
1920
{
2021
"_id": "visualization:response-time-percentile",
@@ -36,7 +37,8 @@ EOF
3637
3738
3839
resource "opensearch_dashboard_object" "test_visualization_v7" {
39-
body = <<EOF
40+
tenant_name = "tenant"
41+
body = <<EOF
4042
[
4143
{
4244
"_id": "response-time-percentile",
@@ -56,7 +58,8 @@ EOF
5658
}
5759
5860
resource "opensearch_dashboard_object" "test_index_pattern_v6" {
59-
body = <<EOF
61+
tenant_name = "tenant"
62+
body = <<EOF
6063
[
6164
{
6265
"_id": "index-pattern:cloudwatch",
@@ -74,7 +77,8 @@ EOF
7477
}
7578
7679
resource "opensearch_dashboard_object" "test_index_pattern_v7" {
77-
body = <<EOF
80+
tenant_name = "tenant"
81+
body = <<EOF
7882
[
7983
{
8084
"_id": "index-pattern:cloudwatch",
@@ -101,7 +105,8 @@ EOF
101105

102106
### Optional
103107

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

106111
### Read-Only
107112

examples/resources/opensearch_dashboard_object/resource.tf

+8-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
resource "opensearch_dashboard_object" "test_visualization_v6" {
3-
body = <<EOF
3+
tenant_name = "tenant"
4+
body = <<EOF
45
[
56
{
67
"_id": "visualization:response-time-percentile",
@@ -22,7 +23,8 @@ EOF
2223

2324

2425
resource "opensearch_dashboard_object" "test_visualization_v7" {
25-
body = <<EOF
26+
tenant_name = "tenant"
27+
body = <<EOF
2628
[
2729
{
2830
"_id": "response-time-percentile",
@@ -42,7 +44,8 @@ EOF
4244
}
4345

4446
resource "opensearch_dashboard_object" "test_index_pattern_v6" {
45-
body = <<EOF
47+
tenant_name = "tenant"
48+
body = <<EOF
4649
[
4750
{
4851
"_id": "index-pattern:cloudwatch",
@@ -60,7 +63,8 @@ EOF
6063
}
6164

6265
resource "opensearch_dashboard_object" "test_index_pattern_v7" {
63-
body = <<EOF
66+
tenant_name = "tenant"
67+
body = <<EOF
6468
[
6569
{
6670
"_id": "index-pattern:cloudwatch",

0 commit comments

Comments
 (0)