Skip to content

Commit

Permalink
Fix invalid count arguments (#78)
Browse files Browse the repository at this point in the history
Same error message as in terraform-aws-modules/terraform-aws-acm#10. This
change enables the cluster to be destroyed in one go.
  • Loading branch information
lbodor authored and tom-butler committed Jul 24, 2019
1 parent fb20a11 commit f9c5995
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions nodes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ data "aws_iam_instance_profile" "node" {
}

data "aws_autoscaling_group" "nodes" {
count = (var.group_enabled ? 1 : 0) * length(data.aws_subnet_ids.nodes.ids)
count = var.group_enabled ? length(data.aws_subnet_ids.nodes.ids) : 0
name = element(module.workers.node_asg_names, count.index)
}

data "aws_autoscaling_group" "spots" {
count = (var.group_enabled && var.spot_nodes_enabled ? 1 : 0) * length(data.aws_subnet_ids.nodes.ids)
count = var.group_enabled && var.spot_nodes_enabled ? length(data.aws_subnet_ids.nodes.ids) : 0
name = element(module.workers.spot_node_asg_names, count.index)
}

Expand Down
2 changes: 1 addition & 1 deletion nodes/modules/workers/worker_image.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resource "aws_launch_template" "node" {
}

resource "aws_launch_template" "spot" {
count = (var.spot_nodes_enabled ? 1 : 0) * length(var.nodes_subnet_group)
count = var.spot_nodes_enabled ? length(var.nodes_subnet_group) : 0
name_prefix = var.cluster_name
image_id = local.ami_id
user_data = base64encode(local.eks-node-userdata)
Expand Down
4 changes: 2 additions & 2 deletions nodes/modules/workers/workers.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
resource "aws_autoscaling_group" "nodes" {
count = (var.nodes_enabled ? 1 : 0) * length(var.nodes_subnet_group)
count = var.nodes_enabled ? length(var.nodes_subnet_group) : 0
desired_capacity = var.desired_nodes
max_size = var.max_nodes
min_size = var.min_nodes
Expand Down Expand Up @@ -44,7 +44,7 @@ resource "aws_autoscaling_group" "nodes" {
}

resource "aws_autoscaling_group" "spot_nodes" {
count = (var.spot_nodes_enabled ? 1 : 0) * length(var.nodes_subnet_group)
count = var.spot_nodes_enabled ? length(var.nodes_subnet_group) : 0
desired_capacity = var.desired_nodes
max_size = var.max_nodes
min_size = var.min_nodes
Expand Down

0 comments on commit f9c5995

Please sign in to comment.