Fixes
This commit is contained in:
parent
ae40c80195
commit
2ffaa5060e
3 changed files with 16 additions and 17 deletions
|
|
@ -85,14 +85,14 @@ module "datasource" {
|
||||||
Thanos-Common-Infra-PRD = {
|
Thanos-Common-Infra-PRD = {
|
||||||
type = "prometheus"
|
type = "prometheus"
|
||||||
url_key = "thanos_coin_prd"
|
url_key = "thanos_coin_prd"
|
||||||
user_key = "thanos_coin_prd"
|
basic_auth_user_key = "thanos_coin_prd"
|
||||||
pass_key = "thanos_coin_prd"
|
pass_key = "thanos_coin_prd"
|
||||||
is_default = true
|
is_default = true
|
||||||
}
|
}
|
||||||
Loki-Common-Infra-PRD = {
|
Loki-Common-Infra-PRD = {
|
||||||
type = "loki"
|
type = "loki"
|
||||||
url_key = "loki_coin_prd"
|
url_key = "loki_coin_prd"
|
||||||
user_key = "loki_coin_prd"
|
basic_auth_user_key = "loki_coin_prd"
|
||||||
pass_key = "loki_coin_prd"
|
pass_key = "loki_coin_prd"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# Step 1: Create the basic "shell" of each datasource.
|
# Create the basic "shell" of each datasource.
|
||||||
resource "grafana_data_source" "this" {
|
resource "grafana_data_source" "this" {
|
||||||
for_each = var.datasources
|
for_each = var.datasources
|
||||||
|
|
||||||
|
|
@ -8,7 +8,6 @@ resource "grafana_data_source" "this" {
|
||||||
is_default = coalesce(each.value.is_default, false)
|
is_default = coalesce(each.value.is_default, false)
|
||||||
|
|
||||||
# For HTTP Basic Auth (Loki, Prometheus, etc.)
|
# For HTTP Basic Auth (Loki, Prometheus, etc.)
|
||||||
# FIX: Changed 'user_key' to 'basic_auth_user_key' to match your variables.tf
|
|
||||||
basic_auth_enabled = each.value.basic_auth_user_key != null
|
basic_auth_enabled = each.value.basic_auth_user_key != null
|
||||||
basic_auth_username = each.value.basic_auth_user_key != null ? var.datasource_users[each.value.basic_auth_user_key] : null
|
basic_auth_username = each.value.basic_auth_user_key != null ? var.datasource_users[each.value.basic_auth_user_key] : null
|
||||||
|
|
||||||
|
|
@ -16,7 +15,7 @@ resource "grafana_data_source" "this" {
|
||||||
# This sets the username initially.
|
# This sets the username initially.
|
||||||
username = each.value.db_user_key != null ? var.datasource_users[each.value.db_user_key] : null
|
username = each.value.db_user_key != null ? var.datasource_users[each.value.db_user_key] : null
|
||||||
|
|
||||||
# CRITICAL FIX: This resource must ignore attributes that are
|
# This resource must ignore attributes that are
|
||||||
# managed by the other 'config' resources below.
|
# managed by the other 'config' resources below.
|
||||||
lifecycle {
|
lifecycle {
|
||||||
ignore_changes = [
|
ignore_changes = [
|
||||||
|
|
@ -28,7 +27,7 @@ resource "grafana_data_source" "this" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 2: Apply the main json_data for datasources like PostgreSQL.
|
# Apply the main json_data for datasources like PostgreSQL.
|
||||||
resource "grafana_data_source_config" "json_data_main" {
|
resource "grafana_data_source_config" "json_data_main" {
|
||||||
for_each = {
|
for_each = {
|
||||||
for k, v in var.datasources : k => v
|
for k, v in var.datasources : k => v
|
||||||
|
|
@ -45,7 +44,7 @@ resource "grafana_data_source_config" "json_data_main" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 3: Apply passwords to all datasources that require one.
|
# Apply passwords to all datasources that require one.
|
||||||
resource "grafana_data_source_config" "passwords" {
|
resource "grafana_data_source_config" "passwords" {
|
||||||
for_each = {
|
for_each = {
|
||||||
for k, v in var.datasources : k => v if v.pass_key != null
|
for k, v in var.datasources : k => v if v.pass_key != null
|
||||||
|
|
@ -67,7 +66,7 @@ resource "grafana_data_source_config" "passwords" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 4: Apply Loki-specific 'derivedFields' configuration.
|
# Apply Loki-specific 'derivedFields' configuration.
|
||||||
resource "grafana_data_source_config" "loki_derived_fields" {
|
resource "grafana_data_source_config" "loki_derived_fields" {
|
||||||
for_each = {
|
for_each = {
|
||||||
for k, v in var.datasources : k => v if v.type == "loki" && v.derived_fields != null
|
for k, v in var.datasources : k => v if v.type == "loki" && v.derived_fields != null
|
||||||
|
|
@ -90,7 +89,7 @@ resource "grafana_data_source_config" "loki_derived_fields" {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Step 5: Apply Tempo-specific 'tracesToLogsV2' configuration.
|
# Apply Tempo-specific 'tracesToLogsV2' configuration.
|
||||||
resource "grafana_data_source_config" "tempo_traces_to_logs" {
|
resource "grafana_data_source_config" "tempo_traces_to_logs" {
|
||||||
for_each = {
|
for_each = {
|
||||||
for k, v in var.datasources : k => v if v.type == "tempo" && v.traces_to_logs != null
|
for k, v in var.datasources : k => v if v.type == "tempo" && v.traces_to_logs != null
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ EOT
|
||||||
# Key to look up a basic auth username
|
# Key to look up a basic auth username
|
||||||
basic_auth_user_key = optional(string)
|
basic_auth_user_key = optional(string)
|
||||||
|
|
||||||
# ADDED BACK: Non-sensitive JSON data for Postgres, etc.
|
# Non-sensitive JSON data for Postgres, etc.
|
||||||
json_data = optional(map(any))
|
json_data = optional(map(any))
|
||||||
|
|
||||||
# Linking Attributes (for Loki/Tempo)
|
# Linking Attributes (for Loki/Tempo)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue