From 7386f5c4cb7d731c3d1143c93bc9306b16f8adb6 Mon Sep 17 00:00:00 2001 From: Joseph Page Date: Fri, 15 Sep 2023 21:28:06 +0200 Subject: [PATCH] feat: add new type of log_drains and validate input --- log_drains.tf | 9 ++++++++- variables.tf | 17 +++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/log_drains.tf b/log_drains.tf index afef088..ee2dbc1 100644 --- a/log_drains.tf +++ b/log_drains.tf @@ -7,5 +7,12 @@ resource "scalingo_log_drain" "log_drain" { app = scalingo_app.app.id type = each.value.type - url = sensitive(each.value.url) + + # Log drain parameters are different depending on the type + url = sensitive(each.value.url) + drain_region = each.value.drain_region + addon = each.value.addon + host = each.value.host + port = each.value.port + token = sensitive(each.value.token) } diff --git a/variables.tf b/variables.tf index 6325705..6610b49 100644 --- a/variables.tf +++ b/variables.tf @@ -184,9 +184,22 @@ variable "domain_aliases" { variable "log_drains" { type = list(object({ - type = string - url = optional(string, "") + type = string + url = optional(string, "") + drain_region = optional(string, "") + addon = optional(string, "") + host = optional(string, "") + port = optional(string, "") + token = optional(string, "") })) default = [] nullable = false + + validation { + condition = length([ + for drain in var.log_drains : + drain if !contains(["elk", "appsignal", "logtail", "datadog", "ovh-graylog", "papertrail", "logtail", "syslog"], drain.type) + ]) == 0 + error_message = "The list of log drains must contain only valid log drains type (elk/appsignal/logtail/datadog/ovh-graylog/papertrail/logtail/syslog)." + } }