Closed the-smooth-operator closed 2 years ago
Are there plans to merge in the fix that @sharath-sequoia mentioned? I'm running into the same issue.
slice()
function also fails if you want to create more nodes than you have defined availability zones. Which is kind of the same as was what reported originally in this issue..
module "redis_test" {
source = "git::https://github.com/cloudposse/terraform-aws-elasticache-redis.git?ref=tags/0.31.0"
name = "redis_test"
vpc_id = module.vpc.vpc_id
subnets = ["subnet-123456", "subnet-789012"]
cluster_size = 4
instance_type = "cache.t3.micro"
availability_zones = ["us-east-1a", "us-east-1b"]
}
terraform plan
Error: Invalid function argument
on .terraform/modules/redis_test/main.tf line 89, in resource "aws_elasticache_replication_group" "default":
89: availability_zones = var.cluster_mode_enabled ? null : slice(var.availability_zones, 0, var.cluster_size)
|----------------
| var.cluster_size is 4
Invalid value for "end_index" parameter: end index must not be greater than
the length of the list.
I noticed this earlier with the memcached module and made a PR for it. I'll make a PR for what @sharath-sequoia had done already and my fix for the amount of nodes.
Unfortunately defining more nodes than AZs will require a fix for AWS provider as well as there seems to be a bug that prevents you from defining duplicate values for availability_zones
parameter on aws_elasticache_replication_group
resource, https://github.com/hashicorp/terraform-provider-aws/issues/14070
I'll do the PR anyways, but that bug explains why I was losing my mind testing the change and couldn't understand why it didn't produce a longer list of AZs 😄
Closed by #108
Describe the Bug
When using the default value for
availability_zones
(i.e: the parameter it's omitted)terraform plan
throws the next error:The problem here is that
slice()
tries to create a non empty slice of an empty list, thus failing. More information on the slice command here.Expected Behavior
terraform plan
runs.Steps to Reproduce
Create a file with this content:
Environment (please complete the following information):
Anything that will help us triage the bug will help. Here are some ideas: