-
-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support more nodes than there are AZs defined #108
Conversation
availability_zones parameter shouldn't be required
@@ -86,7 +86,7 @@ resource "aws_elasticache_replication_group" "default" { | |||
number_cache_clusters = var.cluster_mode_enabled ? null : var.cluster_size | |||
port = var.port | |||
parameter_group_name = join("", aws_elasticache_parameter_group.default.*.name) | |||
availability_zones = var.cluster_mode_enabled ? null : slice(var.availability_zones, 0, var.cluster_size) | |||
availability_zones = length(var.availability_zones) == 0 ? null : [for n in range(0, var.cluster_size) : element(var.availability_zones, n)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious. Is there a difference between slice(var.availability_zones, 0, var.cluster_size) and [for n in range(0, var.cluster_size) : element(var.availability_zones, n)] ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
element()
has this "wrap-around" behavior built in, so if a list has 3 indexes and you ask for the fourth, it will return the first one for you. That enables you to define - for example - var.cluster_size = 3
and var.availability_zones = ["us-east-1a", "us-east-1b"]
, which would fail with slice()
as there are less indexes (2) than you are asking for (3). And element()
function returns just one element at a time, thus the for
loop and range()
to populate the list.
https://www.terraform.io/docs/language/functions/element.html
https://www.terraform.io/docs/language/functions/slice.html
/test all |
/rebuild readme |
/rebuild-readme |
/test readme |
/test all |
@Mergifyio update |
Command
|
/test all |
@hawkesn ^^ |
* allow empty list of availability_zones availability_zones parameter shouldn't be required * enable more nodes to be created than AZs * Updated README.md Co-authored-by: actions-bot <58130806+actions-bot@users.noreply.github.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
what
availability_zones
why
availability_zones
parameter shouldn't be required.references