Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions pages/cockpit/how-to/iam-auth-cockpit-grafana-terraform.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
---
title: How to use IAM auth for Cockpit Grafana with Terraform
description: Learn how to securely manage Cockpit Grafana access and resources using Terraform and IAM authentication.
tags: observability cockpit grafana terraform
dates:
validation: 2025-12-18
posted: 2022-12-19
---

import Requirements from '@macros/iam/requirements.mdx'

<Requirements />

- A Scaleway account with access to the [Scaleway Console](https://console.scaleway.com)
- [IAM permissions – Cockpit](/iam/reference-content/permission-sets/#monitoring): an API key with the required rights to allow Terraform to access Grafana
- The latest versions of the [Scaleway](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs) and [Grafana](https://registry.terraform.io/providers/grafana/grafana/latest/docs) Terraform providers

## Example: Terraform configuration for Accessing Cockpit Grafana

```hcl
scaleway.auto.tfvars :

access_key = "SCWXXXXXXXXXXXXXXXXX"
secret_key = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
organization_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
project_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
```

```hcl
main.tf :

terraform {
required_providers {
scaleway = {
source = "scaleway/scaleway"
version = "2.64.0"
}
grafana = {
source = "grafana/grafana"
version = "4.21.0"
}
}
}

variable "access_key" {
type = string
sensitive = true
}

variable "secret_key" {
type = string
sensitive = true
}

variable "organization_id" {
type = string
sensitive = true
}

variable "project_id" {
type = string
sensitive = true
}

provider "scaleway" {
access_key = var.access_key
secret_key = var.secret_key
organization_id = var.organization_id
project_id = var.project_id
}

provider "grafana" {
url = "https://${var.project_id}.dashboard.cockpit.scaleway.com"
auth = "anonymous"

http_headers = {
"X-Auth-Token" = var.secret_key
}
}
```

<Message type="note">
Using the [Scaleway Terraform provider](https://registry.terraform.io/providers/scaleway/scaleway/latest/docs), you can manage Cockpit-specific resources and actions, including alerting, access tokens, data sources.
</Message>
4 changes: 4 additions & 0 deletions pages/cockpit/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const cockpitMenu = {
label: 'Access Grafana and preconfigured dashboards',
slug: 'access-grafana-and-managed-dashboards',
},
{
label: 'Use IAM auth for Cockpit Grafana with Terraform',
slug: 'iam-auth-cockpit-grafana-terraform',
},
{
label: 'Create a Cockpit token',
slug: 'create-token',
Expand Down