cloudposse / terraform-aws-elasticache-redis

Terraform module to provision an ElastiCache Redis Cluster
https://cloudposse.com/accelerate
Apache License 2.0
142 stars 246 forks source link

Support log delivery configuration #162

Closed stevenpitts closed 2 years ago

stevenpitts commented 2 years ago

Describe the Feature

Allow enabling log delivery configuration on ElastiCache Redis clusters provisioned by this module.

Expected Behavior

There would be an input or set of inputs to this module that specify log delivery configuration. These inputs would be transformed and passed as log_delivery_configuration blocks to the aws_elasticache_replication_group resource.

Use Case

I was having issues connecting to my ElastiCache Redis cluster provisioned by this module, and I figured enabling logs might help debug the issue. Unfortunately, I learned that there is no way to configure this in the module, so I had to manually enable log delivery temporarily. Of course, this makes Terraform state stale until I disable log delivery.

Describe Ideal Solution

A list(map(string)) input named log_delivery_configuration_blocks or similar, which is provided to aws_elasticache_replication_group.default via a dynamic block as log_delivery_configuration blocks. I'm not particularly attached to this specific solution.

Alternatives Considered

I considered enabling log delivery manually and having Terraform ignore changes to aws_elasticache_replication_group.default's log_delivery_configuration blocks, but I don't believe I have the ability to configure that external of the module.

I looked into whether there is an alternate Terraform AWS resource like aws_elasticache_replication_group_log_delivery_configuration which would be resource-based rather than attribute-based (such as s3_bucket's logging field versus the s3_bucket_logging resource), which I could provision outside of the module, but it appears no such resource exists.

Additional Context

Snippet of Terraform wanting to revert my manual changes of enabling log delivery:

- log_delivery_configuration {
    - destination      = "REDACTED" -> null
    - destination_type = "cloudwatch-logs" -> null
    - log_format       = "json" -> null
    - log_type         = "engine-log" -> null
  }
- log_delivery_configuration {
    - destination      = "REDACTED" -> null
    - destination_type = "cloudwatch-logs" -> null
    - log_format       = "json" -> null
    - log_type         = "slow-log" -> null
  }