From bc64c8f673921b2f42756177b31312c8041a5199 Mon Sep 17 00:00:00 2001 From: Soumik Dey Date: Thu, 7 Mar 2024 19:10:55 +0530 Subject: [PATCH] Update log group count and name in aws_cloudwatch_log_group resource --- main.tf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.tf b/main.tf index d6df5d1..cf6386d 100644 --- a/main.tf +++ b/main.tf @@ -121,8 +121,8 @@ data "aws_iam_policy_document" "default" { ## Below resource will create will save logs cloudwatch_log_group resource for redis-cluster and memcached. ##---------------------------------------------------------------------------------- resource "aws_cloudwatch_log_group" "default" { - count = var.enable && length(var.log_delivery_configuration) > 0 ? 1 : 0 - name = format("logs-%s", module.labels.id) + count = var.enable && length(var.log_delivery_configuration) > 0 ? length(var.log_delivery_configuration) : 0 + name = format("%s-%s", module.labels.name, var.log_delivery_configuration[count.index].log_type) retention_in_days = var.retention_in_days tags = module.labels.tags } @@ -186,7 +186,7 @@ resource "aws_elasticache_replication_group" "cluster" { for_each = var.log_delivery_configuration content { - destination = lookup(log_delivery_configuration.value, "destination", join("", aws_cloudwatch_log_group.default[*].name)) + destination = lookup(log_delivery_configuration.value, "destination", aws_cloudwatch_log_group.default[index(var.log_delivery_configuration, log_delivery_configuration.value)].name) destination_type = lookup(log_delivery_configuration.value, "destination_type", null) log_format = lookup(log_delivery_configuration.value, "log_format", null) log_type = lookup(log_delivery_configuration.value, "log_type", null)