Skip to content

Commit d8c6184

Browse files
authored
docs(cockpit): document IAM header for Grafana access (#3464)
1 parent 66053ec commit d8c6184

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

docs/data-sources/cockpit_grafana.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ output "grafana_connection_info" {
6161
}
6262
```
6363

64+
### Using the Grafana Terraform provider
65+
66+
When you need to configure Grafana resources programmatically, supply the IAM secret key as an `X-Auth-Token` header. The Grafana provider itself stays in `anonymous` mode.
67+
68+
```terraform
69+
variable "scaleway_secret_key" {
70+
description = "Scaleway IAM secret key reused by the Grafana provider"
71+
type = string
72+
sensitive = true
73+
}
74+
75+
data "scaleway_cockpit_grafana" "main" {
76+
project_id = scaleway_account_project.project.id
77+
}
78+
79+
provider "grafana" {
80+
url = data.scaleway_cockpit_grafana.main.grafana_url
81+
auth = "anonymous"
82+
83+
http_headers = {
84+
"X-Auth-Token" = var.scaleway_secret_key
85+
}
86+
}
87+
```
88+
89+
Keep the secret key in a secure backend (environment variables, Vault, etc.) and never commit it to source control.
90+
6491
## Argument Reference
6592

6693
- `project_id` - (Optional) The ID of the project the Grafana instance is associated with. If not provided, the default project configured in the provider is used.

docs/resources/cockpit_grafana_user.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,33 @@ output "grafana_url" {
3838
}
3939
```
4040

41+
### Programmatic access with the Grafana provider
42+
43+
To automate Grafana configuration (e.g., dashboards, alerting) with Terraform, reuse your Scaleway IAM secret as an `X-Auth-Token` header. The Grafana provider must run in `anonymous` mode because user/password authentication is deprecated.
44+
45+
```terraform
46+
variable "scaleway_secret_key" {
47+
description = "Scaleway IAM secret key used for both the Scaleway and Grafana providers"
48+
type = string
49+
sensitive = true
50+
}
51+
52+
data "scaleway_cockpit_grafana" "main" {
53+
project_id = scaleway_account_project.project.id
54+
}
55+
56+
provider "grafana" {
57+
url = data.scaleway_cockpit_grafana.main.grafana_url
58+
auth = "anonymous"
59+
60+
http_headers = {
61+
"X-Auth-Token" = var.scaleway_secret_key
62+
}
63+
}
64+
```
65+
66+
The header `X-Auth-Token` is mandatory when Grafana users are disabled. Store the IAM secret key securely (environment variable, secrets manager, etc.) and avoid committing it to version control.
67+
4168
### Create a Grafana user (Deprecated)
4269

4370
The following command allows you to create a Grafana user within a specific Scaleway Project.

templates/data-sources/cockpit_grafana.md.tmpl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,33 @@ output "grafana_connection_info" {
6161
}
6262
```
6363

64+
### Using the Grafana Terraform provider
65+
66+
When you need to configure Grafana resources programmatically, supply the IAM secret key as an `X-Auth-Token` header. The Grafana provider itself stays in `anonymous` mode.
67+
68+
```terraform
69+
variable "scaleway_secret_key" {
70+
description = "Scaleway IAM secret key reused by the Grafana provider"
71+
type = string
72+
sensitive = true
73+
}
74+
75+
data "scaleway_cockpit_grafana" "main" {
76+
project_id = scaleway_account_project.project.id
77+
}
78+
79+
provider "grafana" {
80+
url = data.scaleway_cockpit_grafana.main.grafana_url
81+
auth = "anonymous"
82+
83+
http_headers = {
84+
"X-Auth-Token" = var.scaleway_secret_key
85+
}
86+
}
87+
```
88+
89+
Keep the secret key in a secure backend (environment variables, Vault, etc.) and never commit it to source control.
90+
6491
## Argument Reference
6592

6693
- `project_id` - (Optional) The ID of the project the Grafana instance is associated with. If not provided, the default project configured in the provider is used.

templates/resources/cockpit_grafana_user.md.tmpl

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,33 @@ output "grafana_url" {
3939
}
4040
```
4141

42+
### Programmatic access with the Grafana provider
43+
44+
To automate Grafana configuration (e.g., dashboards, alerting) with Terraform, reuse your Scaleway IAM secret as an `X-Auth-Token` header. The Grafana provider must run in `anonymous` mode because user/password authentication is deprecated.
45+
46+
```terraform
47+
variable "scaleway_secret_key" {
48+
description = "Scaleway IAM secret key used for both the Scaleway and Grafana providers"
49+
type = string
50+
sensitive = true
51+
}
52+
53+
data "scaleway_cockpit_grafana" "main" {
54+
project_id = scaleway_account_project.project.id
55+
}
56+
57+
provider "grafana" {
58+
url = data.scaleway_cockpit_grafana.main.grafana_url
59+
auth = "anonymous"
60+
61+
http_headers = {
62+
"X-Auth-Token" = var.scaleway_secret_key
63+
}
64+
}
65+
```
66+
67+
The header `X-Auth-Token` is mandatory when Grafana users are disabled. Store the IAM secret key securely (environment variable, secrets manager, etc.) and avoid committing it to version control.
68+
4269
### Create a Grafana user (Deprecated)
4370

4471
The following command allows you to create a Grafana user within a specific Scaleway Project.

0 commit comments

Comments
 (0)