provider "vault" {
  skip_child_token = true
}

data "vault_kv_secret_v2" "secret_ext" { # Секреты для подключения к внешним источникам (mm, clickhouse и т.д.)
  mount = "app"
  name  = "groups/monitoring/grafana/dev/ext"
}

data "vault_kv_secret_v2" "secret_int" { # Секреты для работы самой графаны
  mount = "app"
  name  = "groups/monitoring/grafana/dev/int"
}

provider "grafana" {
  alias                = "grafana01"
  url                  = "http://192.168.0.106:3000"
  auth                 = "admin:${data.vault_kv_secret_v2.secret_int.data["grafana_local_admin_password"]}"
  insecure_skip_verify = true
  http_headers         = local.grafana_headers

  # Grafana IRM / OnCall (Grafana Cloud)
  oncall_access_token = try(data.vault_kv_secret_v2.secret_int.data["oncall_access_token"], null)
  oncall_url          = "https://oncall-prod-us-central-0.grafana.net/oncall"
}