Skip to content

Commit

Permalink
grafana user pass add in vars
Browse files Browse the repository at this point in the history
  • Loading branch information
sohanyadav committed Aug 28, 2024
1 parent 53d5705 commit 620f9f7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
17 changes: 17 additions & 0 deletions grafana.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
resource "random_password" "grafana_admin_password" {
count = var.grafana_enabled && var.adminPassword == "" ? 1 : 0
length = 16
special = true
}

resource "helm_release" "grafana" {
count = var.grafana_enabled ? 1 : 0

Expand All @@ -22,6 +28,17 @@ resource "helm_release" "grafana" {
value = var.grafana_persistence_storage
}

set {
name = "adminUser"
value = var.grafana_admin_user
}

set {
name = "adminPassword"
value = var.grafana_admin_password != "" ? var.grafana_admin_password : random_password.grafana_admin_password[0].result

}

dynamic "set" {
for_each = var.grafana_persistence_storage != false ? [1] : []
content {
Expand Down
3 changes: 0 additions & 3 deletions grafana.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
adminUser: opszero
adminPassword: opszero

datasources:
datasources.yaml:
apiVersion: 1
Expand Down
12 changes: 11 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ variable "grafana_enabled" {
description = "Enable grafana"
}

variable "grafana_admin_user" {
default = "opszero"
description = "The User name of Grafana for login Dashboard"
}

variable "grafana_admin_password" {
default = ""
description = "The Password of Grafana for login Dashboard"
}

variable "grafana_ingress_enabled" {
default = false
description = "Enable grafana ingress"
Expand Down Expand Up @@ -117,7 +127,7 @@ variable "resources" {
cpu = string
memory = string
}))
default = null # You can set a default value if needed
default = null # You can set a default value if needed
}

variable "cert_manager_version" {
Expand Down

0 comments on commit 620f9f7

Please sign in to comment.