From 949c4428dc5a941a0b7e179fbb7e671db5ec6267 Mon Sep 17 00:00:00 2001 From: Max Williams Date: Mon, 27 Aug 2018 15:31:00 +0200 Subject: [PATCH] reverting calculation of count for worker groups --- README.md | 1 + data.tf | 2 +- variables.tf | 6 ++++++ workers.tf | 4 ++-- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 781cd6d..e9f2cc2 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a | subnets | A list of subnets to place the EKS cluster and workers within. | list | - | yes | | tags | A map of tags to add to all resources. | map | `` | no | | vpc_id | VPC where the cluster and workers will be deployed. | string | - | yes | +| worker_group_count | The number of maps contained within the worker_groups list. | string | `1` | no | | worker_groups | A list of maps defining worker group configurations. See workers_group_defaults for valid keys. | list | `` | no | | worker_security_group_id | If provided, all workers will be attached to this security group. If not given, a security group will be created with necessary ingres/egress to work with the EKS cluster. | string | `` | no | | worker_sg_ingress_from_port | Minimum port number from which pods will accept communication. Must be changed to a lower value if some pods in your cluster will expose a port lower than 1025 (e.g. 22, 80, or 443). | string | `1025` | no | diff --git a/data.tf b/data.tf index a04e894..3671d1a 100644 --- a/data.tf +++ b/data.tf @@ -71,7 +71,7 @@ EOF data "template_file" "userdata" { template = "${file("${path.module}/templates/userdata.sh.tpl")}" - count = "${length(var.worker_groups)}" + count = "${var.worker_group_count}" vars { region = "${data.aws_region.current.name}" diff --git a/variables.tf b/variables.tf index bc672b6..979d42d 100644 --- a/variables.tf +++ b/variables.tf @@ -69,6 +69,12 @@ variable "worker_groups" { }] } +variable "worker_group_count" { + description = "The number of maps contained within the worker_groups list." + type = "string" + default = "1" +} + variable "workers_group_defaults" { description = "Default values for target groups as defined by the list of maps." type = "map" diff --git a/workers.tf b/workers.tf index 61258ea..77783ff 100644 --- a/workers.tf +++ b/workers.tf @@ -5,7 +5,7 @@ resource "aws_autoscaling_group" "workers" { min_size = "${lookup(var.worker_groups[count.index], "asg_min_size",lookup(var.workers_group_defaults, "asg_min_size"))}" launch_configuration = "${element(aws_launch_configuration.workers.*.id, count.index)}" vpc_zone_identifier = ["${split(",", coalesce(lookup(var.worker_groups[count.index], "subnets", ""), join(",", var.subnets)))}"] - count = "${length(var.worker_groups)}" + count = "${var.worker_group_count}" tags = ["${concat( list( @@ -33,7 +33,7 @@ resource "aws_launch_configuration" "workers" { ebs_optimized = "${lookup(var.worker_groups[count.index], "ebs_optimized", lookup(local.ebs_optimized, lookup(var.worker_groups[count.index], "instance_type", lookup(var.workers_group_defaults, "instance_type")), false))}" enable_monitoring = "${lookup(var.worker_groups[count.index], "enable_monitoring", lookup(var.workers_group_defaults, "enable_monitoring"))}" spot_price = "${lookup(var.worker_groups[count.index], "spot_price", lookup(var.workers_group_defaults, "spot_price"))}" - count = "${length(var.worker_groups)}" + count = "${var.worker_group_count}" lifecycle { create_before_destroy = true