You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An error is found when enabling slow-log and engine-log and in both cases the name of the log-group is not specified so that the module completes it with the default
example to reproduce the error:
provider "aws" {
region = local.region
}
data "aws_availability_zones" "available" {}
locals {
region = "eu-west-1"
name = "ex-${basename(path.cwd)}"
vpc_cidr = "10.0.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)
tags = {
Name = local.name
Example = local.name
Repository = "https://github.com/terraform-aws-modules/terraform-aws-elasticache"
}
}
################################################################################
# ElastiCache Module
################################################################################
module "elasticache" {
source = "../../"
cluster_id = local.name
create_cluster = true
create_replication_group = false
engine_version = "7.1"
node_type = "cache.t4g.small"
maintenance_window = "sun:05:00-sun:09:00"
apply_immediately = true
# Security Group
vpc_id = module.vpc.vpc_id
security_group_rules = {
ingress_vpc = {
# Default type is `ingress`
# Default port is based on the default engine port
description = "VPC traffic"
cidr_ipv4 = module.vpc.vpc_cidr_block
}
}
# Subnet Group
subnet_group_name = local.name
subnet_group_description = "${title(local.name)} subnet group"
subnet_ids = module.vpc.private_subnets
# Parameter Group
create_parameter_group = true
parameter_group_name = local.name
parameter_group_family = "redis7"
parameter_group_description = "${title(local.name)} parameter group"
parameters = [
{
name = "latency-tracking"
value = "yes"
}
]
# Log Configuration
log_delivery_configuration = {
engine-log = {
# cloudwatch_log_group_name = "elasticache-engine-log"
destination_type = "cloudwatch-logs"
log_format = "json"
}
slow-log = {
# cloudwatch_log_group_name = "elasticache-slow-log"
destination_type = "cloudwatch-logs"
log_format = "json"
}
}
tags = local.tags
}
################################################################################
# Supporting Resources
################################################################################
module "vpc" {
source = "terraform-aws-modules/vpc/aws"
version = "~> 5.0"
name = local.name
cidr = local.vpc_cidr
azs = local.azs
public_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k)]
private_subnets = [for k, v in local.azs : cidrsubnet(local.vpc_cidr, 8, k + 10)]
tags = local.tags
}
[✅] ✋ I have searched the open/closed issues and my issue is not listed.
⚠️ Note
Before you submit an issue, please perform the following first:
Remove the local .terraform directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!): rm -rf .terraform/
Re-initialize the project root to pull down modules: terraform init
Re-attempt your terraform plan or apply and check if the issue still persists
Versions
Module version [Required]: 1.2.3
Terraform version: v1.9.6
Provider version(s): aws v5.69.0
Reproduction Code [Required]
Steps to reproduce the behavior:
Expected behavior
Two log groups with different name created:
/aws/elasticache/dmc-prd-example-00-engine
/aws/elasticache/dmc-prd-example-00-slow
Actual behavior
Two log groups with the same name are traing to be created
/aws/elasticache/dmc-prd-example-00
/aws/elasticache/dmc-prd-example-00
Terminal Output Screenshot(s)
Additional context
Possible solution main.tf line 212 replace resource "aws_cloudwatch_log_group" "this" with:
resource "aws_cloudwatch_log_group" "this" {
for_each = { for k, v in var.log_delivery_configuration : k => v if local.create_cloudwatch_log_group && try(v.create_cloudwatch_log_group, true) && try(v.destination_type, "") == "cloudwatch-logs" }
name = format("/aws/elasticache/%s",
coalesce(
try(each.value.cloudwatch_log_group_name, null),
format("%s-%s",coalesce(var.cluster_id, var.replication_group_id, ""),
each.key == "slow-log" ? "slow" : "engine"
)
)
)
retention_in_days = try(each.value.cloudwatch_log_group_retention_in_days, 14)
kms_key_id = try(each.value.cloudwatch_log_group_kms_key_id, null)
skip_destroy = try(each.value.cloudwatch_log_group_skip_destroy, null)
log_group_class = try(each.value.cloudwatch_log_group_class, null)
tags = merge(local.tags, try(each.value.tags, {}))
}
The text was updated successfully, but these errors were encountered:
Description
An error is found when enabling slow-log and engine-log and in both cases the name of the log-group is not specified so that the module completes it with the default
example to reproduce the error:
Before you submit an issue, please perform the following first:
.terraform
directory (! ONLY if state is stored remotely, which hopefully you are following that best practice!):rm -rf .terraform/
terraform init
Versions
Module version [Required]: 1.2.3
Terraform version: v1.9.6
Provider version(s): aws v5.69.0
Reproduction Code [Required]
Steps to reproduce the behavior:
Expected behavior
Two log groups with different name created:
Actual behavior
Two log groups with the same name are traing to be created
Terminal Output Screenshot(s)
Additional context
Possible solution
main.tf
line212
replaceresource "aws_cloudwatch_log_group" "this"
with:The text was updated successfully, but these errors were encountered: