From e0129e2d527c296d4695b1e0dc266675182664e0 Mon Sep 17 00:00:00 2001 From: erjondibranica Date: Fri, 26 Jul 2024 11:10:26 -0400 Subject: [PATCH] parameterize helm release --- modules/otc-prometheus-exporter/main.tf | 20 ++++++++++-- modules/otc-prometheus-exporter/variables.tf | 33 ++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) diff --git a/modules/otc-prometheus-exporter/main.tf b/modules/otc-prometheus-exporter/main.tf index d4142ba..32855f5 100644 --- a/modules/otc-prometheus-exporter/main.tf +++ b/modules/otc-prometheus-exporter/main.tf @@ -1,7 +1,8 @@ + resource "helm_release" "otc-prometheus-exporter" { name = var.release_name - repository = "https://iits-consulting.github.io/otc-prometheus-exporter/" - chart = "otc-prometheus-exporter" + repository = var.chart_repository + chart = var.chart_name version = var.release_version namespace = var.release_namespace @@ -13,6 +14,21 @@ resource "helm_release" "otc-prometheus-exporter" { dependency_update = true wait_for_jobs = true + dynamic "set" { + for_each = toset(var.chart_set_parameter) + content { + name = set.value.name + value = set.value.value + } + } + dynamic "set_sensitive" { + for_each = toset(var.chart_set_sensitive_parameter) + content { + name = set_sensitive.value.name + value = set_sensitive.value.value + } + } + values = [yamlencode({ deployment = { env = { diff --git a/modules/otc-prometheus-exporter/variables.tf b/modules/otc-prometheus-exporter/variables.tf index 1781952..834b471 100644 --- a/modules/otc-prometheus-exporter/variables.tf +++ b/modules/otc-prometheus-exporter/variables.tf @@ -24,3 +24,36 @@ variable "release_version" { type = string description = "Release version of the chart (see releases on https://github.com/iits-consulting/otc-prometheus-exporter/tree/gh-pages)" } + + + +variable "chart_repository" { + type = string + default = "https://iits-consulting.github.io/otc-prometheus-exporter/" + description = "Chart repository of the IITS otc-prometheus-exporter chart." +} + + +variable "chart_name" { + type = string + default = "otc-prometheus-exporter" + description = "Name of the IITS otc-prometheus-exporter chart." +} + +variable "chart_set_parameter" { + type = list(object({ + name = string + value = string + })) + default = [] + description = "Override the values of the IITS otc-prometheus-exporter chart using set." +} + +variable "chart_set_sensitive_parameter" { + type = list(object({ + name = string + value = string + })) + default = [] + description = "Override the values of the IITS otc-prometheus-exporter chart using set_sensitive." +}