cloudposse / terraform-aws-elasticache-redis

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

Cannot Disable Cluster Mode #180

Closed milldr closed 9 months ago

milldr commented 1 year ago

Describe the Bug

If the module is already deployed with cluster mode enabled, attempting to modify the deployment to disable cluster mode will fail

Expected Behavior

The cluster should be able to be modified to non-cluster mode

Steps to Reproduce

Deploy the resource with cluster mode enabled, via

cluster_mode_enabled = true
cluster_mode_num_node_groups = 3
cluster_mode_replicas_per_node_group = 2

Now disable cluster mode and redeploy

cluster_mode_enabled = false
cluster_mode_num_node_groups = 0
cluster_mode_replicas_per_node_group = 0

Screenshots

╷
│ Error: Invalid function argument
│
│   on .terraform/modules/redis_clusters.redis/main.tf line 223, in module "dns":
│  223:   records  = var.cluster_mode_enabled ? [join("", aws_elasticache_replication_group.default.*.configuration_endpoint_address)] : [join("", aws_elasticache_replication_group.default.*.primary_endpoint_address)]
│     ├────────────────
│     │ while calling join(separator, lists...)
│     │ aws_elasticache_replication_group.default is tuple with 1 element
│
│ Invalid value for "lists" parameter: element 0 is null; cannot concatenate null values.
╵
╷
│ Error: Invalid function argument
│
│   on .terraform/modules/redis_clusters.redis/outputs.tf line 22, in output "endpoint":
│   22:   value       = var.cluster_mode_enabled ? join("", aws_elasticache_replication_group.default.*.configuration_endpoint_address) : join("", aws_elasticache_replication_group.default.*.primary_endpoint_address)
│     ├────────────────
│     │ while calling join(separator, lists...)
│     │ aws_elasticache_replication_group.default is tuple with 1 element
│
│ Invalid value for "lists" parameter: element 0 is null; cannot concatenate null values.
╵
Releasing state lock. This may take a few moments...
exit status 1

Environment (please complete the following information):

milldr commented 1 year ago

As a workaround, we can destroy the module entirely and redeploy