Skip to content

Commit b1eafa3

Browse files
Mark the global org_id as deprecated (#980)
* Mark the global `org_id` as deprecated Reasons: - `org_id` does not work with all resources. Ex: `grafana_user` is not org-scoped, alerting resources have their own `org_id` attribute and the API is different where the global attribute does NOT work. This is very confusing for users - This allows us to make the docs lighter. Less options is simpler for users * Remove `provider-organization.tf` docs
1 parent e3c8585 commit b1eafa3

File tree

10 files changed

+20
-72
lines changed

10 files changed

+20
-72
lines changed

.drone/drone.jsonnet

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ local localTestPipeline(version, name='oss tests: %s' % version, makeTarget='tes
9090
GRAFANA_URL: 'http://grafana:3000',
9191
GRAFANA_AUTH: 'admin:admin',
9292
GRAFANA_VERSION: version,
93-
GRAFANA_ORG_ID: 1,
9493
TF_ACC_TERRAFORM_PATH: terraformPath,
9594
},
9695
},
@@ -216,7 +215,6 @@ local localTestPipeline(version, name='oss tests: %s' % version, makeTarget='tes
216215
GRAFANA_URL: fromSecret(secrets.cloudInstanceUrl),
217216
GRAFANA_AUTH: fromSecret(secrets.apiToken),
218217
GRAFANA_SM_ACCESS_TOKEN: fromSecret(secrets.smToken),
219-
GRAFANA_ORG_ID: 1,
220218
GRAFANA_ONCALL_ACCESS_TOKEN: fromSecret(secrets.onCallToken),
221219
TF_ACC_TERRAFORM_PATH: terraformPath,
222220
},

.drone/drone.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ steps:
146146
from_secret: grafana-api-token
147147
GRAFANA_ONCALL_ACCESS_TOKEN:
148148
from_secret: grafana-oncall-token
149-
GRAFANA_ORG_ID: 1
150149
GRAFANA_SM_ACCESS_TOKEN:
151150
from_secret: grafana-sm-token
152151
GRAFANA_URL:
@@ -188,7 +187,6 @@ steps:
188187
- make testacc-enterprise
189188
environment:
190189
GRAFANA_AUTH: admin:admin
191-
GRAFANA_ORG_ID: 1
192190
GRAFANA_URL: http://grafana:3000
193191
GRAFANA_VERSION: 10.0.1
194192
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
@@ -226,7 +224,6 @@ steps:
226224
- make testacc-oss
227225
environment:
228226
GRAFANA_AUTH: admin:admin
229-
GRAFANA_ORG_ID: 1
230227
GRAFANA_URL: http://grafana:3000
231228
GRAFANA_VERSION: 10.0.1
232229
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
@@ -264,7 +261,6 @@ steps:
264261
- make testacc-oss
265262
environment:
266263
GRAFANA_AUTH: admin:admin
267-
GRAFANA_ORG_ID: 1
268264
GRAFANA_URL: http://grafana:3000
269265
GRAFANA_VERSION: 9.5.5
270266
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
@@ -302,7 +298,6 @@ steps:
302298
- make testacc-oss
303299
environment:
304300
GRAFANA_AUTH: admin:admin
305-
GRAFANA_ORG_ID: 1
306301
GRAFANA_URL: http://grafana:3000
307302
GRAFANA_VERSION: 9.4.13
308303
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
@@ -340,7 +335,6 @@ steps:
340335
- make testacc-oss
341336
environment:
342337
GRAFANA_AUTH: admin:admin
343-
GRAFANA_ORG_ID: 1
344338
GRAFANA_URL: http://grafana:3000
345339
GRAFANA_VERSION: 9.3.16
346340
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
@@ -378,7 +372,6 @@ steps:
378372
- make testacc-oss
379373
environment:
380374
GRAFANA_AUTH: admin:admin
381-
GRAFANA_ORG_ID: 1
382375
GRAFANA_URL: http://grafana:3000
383376
GRAFANA_VERSION: 8.5.27
384377
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
@@ -416,7 +409,6 @@ steps:
416409
- make testacc-oss
417410
environment:
418411
GRAFANA_AUTH: admin:admin
419-
GRAFANA_ORG_ID: 1
420412
GRAFANA_URL: http://grafana:3000
421413
GRAFANA_VERSION: 7.5.17
422414
TF_ACC_TERRAFORM_PATH: /drone/terraform-provider-grafana/terraform
@@ -475,6 +467,6 @@ kind: secret
475467
name: grafana-sm-token
476468
---
477469
kind: signature
478-
hmac: 3c7fc35c0dff49399ef4c8614a9435f9285435f6e8a248c2de4c1960d3a448b4
470+
hmac: 81801e1fc60765938704576fee2d11b1cbd8b2f98d17342c013e526b6da5de38
479471

480472
...

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ installation:
6565

6666
GRAFANA_URL=http://localhost:3000 \
6767
GRAFANA_AUTH=admin:admin \
68-
GRAFANA_ORG_ID=1 \
6968
make testacc
7069
```
7170

@@ -80,7 +79,6 @@ It is only possible to run tests for Grafana Enterprise using local environment.
8079

8180
GRAFANA_URL=http://localhost:3000 \
8281
GRAFANA_AUTH=admin:admin \
83-
GRAFANA_ORG_ID=1 \
8482
make testacc-enterprise
8583
```
8684

docker-compose.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ services:
1111
environment:
1212
- GRAFANA_URL=http://grafana:3000
1313
- GRAFANA_AUTH=admin:admin
14-
- GRAFANA_ORG_ID=1
1514
- GRAFANA_VERSION
1615
working_dir: /go/src/github.com/grafana/terraform-provider-grafana
1716
volumes:

docs/index.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,16 @@ provider "grafana" {
1919
url = "http://grafana.example.com/"
2020
auth = var.grafana_auth
2121
}
22-
```
23-
24-
### Creating a Grafana organization provider (on-premise)
25-
26-
```terraform
27-
// Step 1: Create an organization
28-
provider "grafana" {
29-
alias = "base"
30-
url = "http://grafana.example.com/"
31-
auth = var.grafana_auth
32-
}
3322
23+
// Optional (On-premise, not supported in Grafana Cloud): Create an organization
3424
resource "grafana_organization" "my_org" {
35-
provider = grafana.base
36-
name = "my_org"
37-
}
38-
39-
// Step 2: Create resources within the organization
40-
provider "grafana" {
41-
alias = "my_org"
42-
url = "http://grafana.example.com/"
43-
auth = var.grafana_auth
44-
org_id = grafana_organization.my_org.org_id
25+
name = "my_org"
4526
}
4627
28+
// Create resources (optional: within the organization)
4729
resource "grafana_folder" "my_folder" {
48-
provider = grafana.my_org
49-
50-
title = "Test Folder"
30+
org_id = grafana_organization.my_org.org_id
31+
title = "Test Folder"
5132
}
5233
```
5334

@@ -219,7 +200,7 @@ resource "grafana_oncall_escalation" "example_notify_step" {
219200
- `insecure_skip_verify` (Boolean) Skip TLS certificate verification. May alternatively be set via the `GRAFANA_INSECURE_SKIP_VERIFY` environment variable.
220201
- `oncall_access_token` (String, Sensitive) A Grafana OnCall access token. May alternatively be set via the `GRAFANA_ONCALL_ACCESS_TOKEN` environment variable.
221202
- `oncall_url` (String) An Grafana OnCall backend address. May alternatively be set via the `GRAFANA_ONCALL_URL` environment variable.
222-
- `org_id` (Number) The default organization id to operate on within grafana. For resources that have an `org_id` attribute, the resource-level attribute has priority. May alternatively be set via the `GRAFANA_ORG_ID` environment variable.
203+
- `org_id` (Number, Deprecated) Deprecated: Use the `org_id` attributes on resources instead.
223204
- `retries` (Number) The amount of retries to use for Grafana API and Grafana Cloud API calls. May alternatively be set via the `GRAFANA_RETRIES` environment variable.
224205
- `retry_status_codes` (Set of String) The status codes to retry on for Grafana API and Grafana Cloud API calls. Use `x` as a digit wildcard. Defaults to 429 and 5xx. May alternatively be set via the `GRAFANA_RETRY_STATUS_CODES` environment variable.
225206
- `sm_access_token` (String, Sensitive) A Synthetic Monitoring access token. May alternatively be set via the `GRAFANA_SM_ACCESS_TOKEN` environment variable.

examples/provider/provider-organization.tf

Lines changed: 0 additions & 25 deletions
This file was deleted.

examples/provider/provider.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@ provider "grafana" {
22
url = "http://grafana.example.com/"
33
auth = var.grafana_auth
44
}
5+
6+
// Optional (On-premise, not supported in Grafana Cloud): Create an organization
7+
resource "grafana_organization" "my_org" {
8+
name = "my_org"
9+
}
10+
11+
// Create resources (optional: within the organization)
12+
resource "grafana_folder" "my_folder" {
13+
org_id = grafana_organization.my_org.org_id
14+
title = "Test Folder"
15+
}

internal/provider/provider.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,9 @@ func Provider(version string) func() *schema.Provider {
197197
"org_id": {
198198
Type: schema.TypeInt,
199199
Optional: true,
200+
Deprecated: "Use the `org_id` attributes on resources instead.",
200201
DefaultFunc: schema.EnvDefaultFunc("GRAFANA_ORG_ID", 1),
201-
Description: "The default organization id to operate on within grafana. For resources that have an `org_id` attribute, the resource-level attribute has priority. May alternatively be set via the `GRAFANA_ORG_ID` environment variable.",
202+
Description: "Deprecated: Use the `org_id` attributes on resources instead.",
202203
},
203204
"tls_key": {
204205
Type: schema.TypeString,

internal/testutils/provider.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ func CheckOSSTestsEnabled(t *testing.T) {
123123
CheckEnvVarsSet(t,
124124
"GRAFANA_URL",
125125
"GRAFANA_AUTH",
126-
"GRAFANA_ORG_ID",
127126
"GRAFANA_VERSION",
128127
)
129128
}
@@ -167,7 +166,6 @@ func CheckCloudInstanceTestsEnabled(t *testing.T) {
167166
CheckEnvVarsSet(t,
168167
"GRAFANA_URL",
169168
"GRAFANA_AUTH",
170-
"GRAFANA_ORG_ID",
171169
"GRAFANA_SM_ACCESS_TOKEN",
172170
"GRAFANA_ONCALL_ACCESS_TOKEN",
173171
)
@@ -184,6 +182,5 @@ func CheckEnterpriseTestsEnabled(t *testing.T) {
184182
CheckEnvVarsSet(t,
185183
"GRAFANA_URL",
186184
"GRAFANA_AUTH",
187-
"GRAFANA_ORG_ID",
188185
)
189186
}

templates/index.md.tmpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@ The Grafana provider provides configuration management resources for
1616

1717
{{ tffile "examples/provider/provider.tf" }}
1818

19-
### Creating a Grafana organization provider (on-premise)
20-
21-
{{ tffile "examples/provider/provider-organization.tf" }}
22-
2319
### Creating a Grafana Cloud stack provider
2420

2521
{{ tffile "examples/provider/provider-cloud.tf" }}

0 commit comments

Comments
 (0)