terraform-provider-stackit icon indicating copy to clipboard operation
terraform-provider-stackit copied to clipboard

stackit_observability_instance add an option to load dashboards

Open fjvela opened this issue 11 months ago • 2 comments

Hello!

It will be great to add an option to import dashboards in the observability instance using:

  • dashboard id
  • URL to a JSON file
  • the JSON file

Regards,

fjvela avatar Jan 31 '25 13:01 fjvela

Hi @fjvela,

thanks for opening this issue. We'll have a look on this.

marceljk avatar Feb 03 '25 09:02 marceljk

This code might be helpful for you.

terraform {
  required_version = "~> 1.9.1"
  required_providers {
    grafana = {
      source  = "grafana/grafana"
      version = "~> 3.7.0"
    }
  }
}
provider "grafana" {
  auth = "${var.grafana_username}:${var.grafana_password}"
  url  = var.grafana_url
}
...

resource "grafana_folder" "services" {
  title = "Services"
}

resource "grafana_folder_permission" "services_folder_permissions" {
  folder_uid = grafana_folder.services.uid
  permissions {
    role       = "Editor"
    permission = "Edit"
  }
  permissions {
    role       = "Viewer"
    permission = "View"
  }
}

resource "grafana_dashboard" "backup-service" {
  folder = grafana_folder.services.uid
  config_json = templatefile("${path.module}/configs/backup-service.json", {
    stage  = var.stage
    region = var.region
  })
  overwrite = true
} 

For credentials we use the grafana_initial_admin_* values from our observability instance created in terraform https://registry.terraform.io/providers/stackitcloud/stackit/latest/docs/resources/observability_instance#read-only

h3adex avatar Feb 12 '25 10:02 h3adex