reverting calculation of count for worker groups

This commit is contained in:
Max Williams
2018-08-27 15:31:00 +02:00
parent 0f5e36862e
commit 949c4428dc
4 changed files with 10 additions and 3 deletions

View File

@@ -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 | `<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 | `<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 |

View File

@@ -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}"

View File

@@ -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"

View File

@@ -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