From 21904e6eaa0847745a3957a207241d38089c4de6 Mon Sep 17 00:00:00 2001 From: viktoryathegreat Date: Tue, 26 Dec 2023 14:55:39 +0400 Subject: [PATCH 1/2] fix(DMVP-3234): Added mariadb case --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index 5a0b7b9..e90d11d 100644 --- a/main.tf +++ b/main.tf @@ -1,12 +1,12 @@ locals { vpc_security_group_ids = var.create_security_group ? [module.security_group[0].security_group_id] : var.vpc_security_group_ids - enabled_cloudwatch_logs_exports = (var.engine == "mysql" && var.slow_queries.enabled) ? ["slowquery"] : (var.engine == "postgres" && var.slow_queries.enabled) ? ["postgresql"] : var.enabled_cloudwatch_logs_exports + enabled_cloudwatch_logs_exports = ((var.engine == "mysql" || var.engine == "mariadb") && var.slow_queries.enabled) ? ["slowquery"] : (var.engine == "postgres" && var.slow_queries.enabled) ? ["postgresql"] : var.enabled_cloudwatch_logs_exports # Cloudwatch log groups from which log based metrics are created in case slow queries are enabled cloudwatch_log_groups = var.slow_queries.enabled ? { for type in local.enabled_cloudwatch_logs_exports : type => "/aws/rds/instance/${var.identifier}/${type}" } : {} create_db_parameter_group = var.slow_queries.enabled ? true : var.create_db_parameter_group parameter_group_name = local.create_db_parameter_group ? "${var.identifier}-${var.engine}" : null postgres_slow_queries_duration = var.slow_queries.query_duration * 1000 - port = var.engine == "mysql" ? 3306 : var.engine == "postgres" ? 5432 : var.port + port = (var.engine == "mysql" || var.engine == "mariadb") ? 3306 : var.engine == "postgres" ? 5432 : var.port default_params_mysql = [ { name = "slow_query_log" @@ -44,7 +44,7 @@ locals { user_params_map = { for p in var.parameters : p.name => p.value } # Merge the two maps, with user parameters overriding defaults - merged_params_map = (var.engine == "mysql" && var.slow_queries.enabled) ? merge(local.params_mysql, local.user_params_map) : (var.engine == "postgres" && var.slow_queries.enabled) ? merge(local.params_postgres, local.user_params_map) : {} + merged_params_map = ((var.engine == "mysql" || var.engine == "mariadb") && var.slow_queries.enabled) ? merge(local.params_mysql, local.user_params_map) : (var.engine == "postgres" && var.slow_queries.enabled) ? merge(local.params_postgres, local.user_params_map) : {} # Convert the merged map back to a list of maps combined_parameters = [for name, value in local.merged_params_map : { name = name, value = value }] From 45ef5bc28d5040140593108f8cb7218f413f8548 Mon Sep 17 00:00:00 2001 From: viktoryathegreat Date: Wed, 27 Dec 2023 20:07:24 +0400 Subject: [PATCH 2/2] fix(DMVP-3234): Changed parameter group family config --- main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.tf b/main.tf index e90d11d..1dcaf0f 100644 --- a/main.tf +++ b/main.tf @@ -99,7 +99,7 @@ module "db" { # DB parameter group configs create_db_parameter_group = local.create_db_parameter_group - family = "${var.engine}${var.engine_version}" + family = var.engine == "postgres" ? "${var.engine}${split(".", var.engine_version)[0]}" : "${var.engine}${var.engine_version}" parameter_group_name = local.parameter_group_name parameter_group_use_name_prefix = false parameter_group_description = "Custom parameter group for ${var.identifier}"