From bef39ef7028a8b990502fdaff571db88b0beb4ef Mon Sep 17 00:00:00 2001 From: Orla Dunlop <94905017+odunlop@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:24:22 +0100 Subject: [PATCH] feat(ecs): add ability to add additional vars to control plane (#115) Signed-off-by: Orla Dunlop --- main.tf | 2 ++ modules/ecs/main.tf | 1 + modules/ecs/variables.tf | 5 +++++ templates/ecs/kong_control_plane.tpl | 8 ++++++++ variables.tf | 6 ++++++ 5 files changed, 22 insertions(+) diff --git a/main.tf b/main.tf index c9ce358..d37ff95 100644 --- a/main.tf +++ b/main.tf @@ -171,6 +171,8 @@ module "kong_ecs" { nginx_custom_config = file(coalesce(var.nginx_custom_config_path, local.nginx_default_custom_config_path)) + additional_vars = var.additional_vars + ssl_cert = var.ssl_cert ssl_key = var.ssl_key lua_ssl_cert = var.lua_ssl_cert diff --git a/modules/ecs/main.tf b/modules/ecs/main.tf index e5653ce..d3f8103 100644 --- a/modules/ecs/main.tf +++ b/modules/ecs/main.tf @@ -42,6 +42,7 @@ resource "aws_ecs_task_definition" "kong" { db_password_arn = var.db_password_arn pg_max_concurrent_queries = var.pg_max_concurrent_queries pg_keepalive_timeout = var.pg_keepalive_timeout + additional_vars = var.additional_vars kong_admin_gui_session_conf = var.kong_admin_gui_session_conf log_group = var.log_group admin_api_port = var.kong_ports.admin_api diff --git a/modules/ecs/variables.tf b/modules/ecs/variables.tf index b20f99a..166314f 100644 --- a/modules/ecs/variables.tf +++ b/modules/ecs/variables.tf @@ -384,3 +384,8 @@ variable "vitals_tsdb_address" { description = "Time series database address for Vitals e.g. my-prometheus.net:9090" type = string } + +variable "additional_vars" { + description = "Map of additional environment variables to set in the Control Plane" + type = map(string) +} diff --git a/templates/ecs/kong_control_plane.tpl b/templates/ecs/kong_control_plane.tpl index 8d7d689..5952aa6 100644 --- a/templates/ecs/kong_control_plane.tpl +++ b/templates/ecs/kong_control_plane.tpl @@ -193,6 +193,14 @@ "name": "KONG_VITALS_TSDB_ADDRESS", "value": "${vitals_tsdb_address}" } + %{ if additional_vars != null } + %{ for name, value in additional_vars ~} + ,{ + "name": "${name}", + "value": "${value}" + } + %{ endfor ~} + %{ endif } ], "secrets": [ { diff --git a/variables.tf b/variables.tf index 734127c..2ef6e09 100644 --- a/variables.tf +++ b/variables.tf @@ -890,3 +890,9 @@ variable "kong_plugins" { type = list(string) default = [] } + +variable "additional_vars" { + description = "(Optional) Map of additional environment variables to set in the Control Plane" + type = map(string) + default = null +}