Skip to content

Commit b9628bc

Browse files
committed
Allow log_delivery_group input to be null
This change is created to fix a problem when trying to use this module as DRY code. The log_delivery_group variable expects a map, which it will turn into the log delivery configuration. There is a default map provided in this module, which creates the slow-log log group. 1. Say you create a new root module calling this elasticache submodule. You want to use this same root module for all your environments, and just pass the root module different values to determine what it does in different environments. 2. You use this new root module to deploy production with the default values here. default slow-log group is created. 3. You deploy non-production, passing in a custom slow-log configuration. the custom slow-log is created. 4. You go back to deploy production, but there is a problem now. Since your root module is always passing in some input variable to the elasticache submodule, the default value is always overridden. The only way to get production to work again is to duplicate the default variable from this elasticache module, into your own root module's variable, as its default. Now you have to duplicate this module's variable defaults in your root module. Not very DRY, and could cause issues later if the elasticache module changes and now your root module's defaults don't apply anymore. Add `nullable = false` to the elasticache module's input variable. This prevents you from passing in a null value to the input. If you pass in a null, Terraform will simply ignore the input as if it was never passed. Terraform can't use a null here anyway; it dies saying it expects a map value, not a null. So this doesn't break any existing functionality, but it does allow a root module to pass a default `null` value for this input variable, which makes the elasticache module use its default value.
1 parent d10bc36 commit b9628bc

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

variables.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ variable "ip_discovery" {
8282

8383
variable "log_delivery_configuration" {
8484
description = "(Redis OSS or Valkey) Specifies the destination and format of Redis OSS/Valkey SLOWLOG or Redis OSS/Valkey Engine Log"
85+
nullable = false
8586
type = any
8687
default = {
8788
slow-log = {

0 commit comments

Comments
 (0)