Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variable defaults #33

Merged
merged 1 commit into from
Sep 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion grafana/config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ data "archive_file" "config" {


source {
content = templatefile("${path.module}/config/runtime.txt", { runtime_version = var.runtime_version })
content = templatefile("${path.module}/config/runtime.txt", local.runtime_variables)
filename = "runtime.txt"
}

Expand Down
9 changes: 6 additions & 3 deletions grafana/input.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ variable "monitoring_space_id" {}

variable "prometheus_endpoint" {}

variable "runtime_version" { default = "6.5.1" }
variable "runtime_version" { default = "" }

variable "google_client_id" { default = "" }
variable "google_client_secret" { default = "" }
Expand All @@ -25,8 +25,9 @@ variable "json_dashboards" { default = [] }
variable "extra_datasources" { default = [] }

locals {
dashboard_list = fileset(path.module, "dashboards/*.json")
dashboards = [for f in local.dashboard_list : file("${path.module}/${f}")]
default_runtime_version = "6.5.1"
dashboard_list = fileset(path.module, "dashboards/*.json")
dashboards = [for f in local.dashboard_list : file("${path.module}/${f}")]
grafana_ini_variables = {
google_client_id = var.google_client_id
google_client_secret = var.google_client_secret
Expand All @@ -45,4 +46,6 @@ locals {
influxdb_username = var.influxdb_credentials.username
influxdb_password = var.influxdb_credentials.password
}
runtime_version = var.runtime_version != "" ? var.runtime_version : local.default_runtime_version
runtime_variables = { runtime_version = local.runtime_version }
}
8 changes: 6 additions & 2 deletions prometheus/input.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ variable "exporters" { default = [] }

variable "alertmanager_endpoint" { default = "" }

variable "memory" { default = 1024 }
variable "memory" { default = "" }

variable "disk_quota" { default = 1024 }
variable "disk_quota" { default = "" }

variable "influxdb_service_instance_id" {}

Expand All @@ -26,6 +26,10 @@ variable "internal_apps" { default = [] }

locals {
docker_image_tag = "v2.29.1"
default_memory = 1024
memory = var.memory != "" ? var.memory : local.default_memory
default_disk_quota = 1024
disk_quota = var.disk_quota != "" ? var.disk_quota : local.default_disk_quota
app_name = "prometheus-${var.monitoring_instance_name}"
default_scrape_interval = "15s"
exporters = [for exporter in var.exporters :
Expand Down
4 changes: 2 additions & 2 deletions prometheus/resources.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ resource "cloudfoundry_route" "prometheus" {
resource "cloudfoundry_app" "prometheus" {
name = local.app_name
space = var.monitoring_space_id
memory = var.memory
disk_quota = var.disk_quota
memory = local.memory
disk_quota = local.disk_quota
command = "echo \"$${PROM_CONFIG}\" > /etc/prometheus/prometheus.yml; echo \"$${ALERT_RULES}\" > /etc/prometheus/alert.rules; ${local.default_command} --storage.tsdb.retention.time 1h"
docker_image = "prom/prometheus:${local.docker_image_tag}"
environment = {
Expand Down
6 changes: 3 additions & 3 deletions prometheus_all/input.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ variable "grafana_google_jwt" {
}
variable "grafana_runtime_version" {
description = "Override default Grafana version. See Grafana module for current default version."
default = null
default = ""
}

variable "grafana_elasticsearch_credentials" {
Expand All @@ -82,11 +82,11 @@ variable "grafana_elasticsearch_credentials" {

variable "prometheus_memory" {
description = "Override default prometheus application allocated memory. See Prometheus module for current default value."
default = null
default = ""
}
variable "prometheus_disk_quota" {
description = "Override default prometheus application allocated disk space. See Prometheus module for current default value."
default = null
default = ""
}

variable "influxdb_service_plan" {
Expand Down