From d8f4dfc7646127f980f8a89f55d96d73ce54859f Mon Sep 17 00:00:00 2001 From: Tibo Beijen Date: Tue, 26 Nov 2019 11:41:31 +0100 Subject: [PATCH] Replaced all incorrect aws_eks_cluster.this[count.index] references (there will be just one, so using '[0]'). --- aws_auth.tf | 2 +- workers.tf | 28 ++++++++++++++-------------- workers_launch_template.tf | 16 ++++++++-------- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/aws_auth.tf b/aws_auth.tf index 040eaa7b..8207ce3f 100644 --- a/aws_auth.tf +++ b/aws_auth.tf @@ -31,7 +31,7 @@ EOS triggers = { kube_config_map_rendered = data.template_file.kubeconfig[0].rendered config_map_rendered = data.template_file.config_map_aws_auth[0].rendered - endpoint = aws_eks_cluster.this[count.index].endpoint + endpoint = aws_eks_cluster.this[0].endpoint } } diff --git a/workers.tf b/workers.tf index fe67ba65..ce0f1e22 100644 --- a/workers.tf +++ b/workers.tf @@ -6,7 +6,7 @@ resource "aws_autoscaling_group" "workers" { "-", compact( [ - aws_eks_cluster.this[count.index].name, + aws_eks_cluster.this[0].name, lookup(var.worker_groups[count.index], "name", count.index), lookup(var.worker_groups[count.index], "asg_recreate_on_change", local.workers_group_defaults["asg_recreate_on_change"]) ? random_pet.workers[count.index].id : "" ] @@ -91,16 +91,16 @@ resource "aws_autoscaling_group" "workers" { [ { "key" = "Name" - "value" = "${aws_eks_cluster.this[count.index].name}-${lookup(var.worker_groups[count.index], "name", count.index)}-eks_asg" + "value" = "${aws_eks_cluster.this[0].name}-${lookup(var.worker_groups[count.index], "name", count.index)}-eks_asg" "propagate_at_launch" = true }, { - "key" = "kubernetes.io/cluster/${aws_eks_cluster.this[count.index].name}" + "key" = "kubernetes.io/cluster/${aws_eks_cluster.this[0].name}" "value" = "owned" "propagate_at_launch" = true }, { - "key" = "k8s.io/cluster/${aws_eks_cluster.this[count.index].name}" + "key" = "k8s.io/cluster/${aws_eks_cluster.this[0].name}" "value" = "owned" "propagate_at_launch" = true }, @@ -114,8 +114,8 @@ resource "aws_autoscaling_group" "workers" { "propagate_at_launch" = false }, { - "key" = "k8s.io/cluster-autoscaler/${aws_eks_cluster.this[count.index].name}" - "value" = aws_eks_cluster.this[count.index].name + "key" = "k8s.io/cluster-autoscaler/${aws_eks_cluster.this[0].name}" + "value" = aws_eks_cluster.this[0].name "propagate_at_launch" = false }, { @@ -144,7 +144,7 @@ resource "aws_autoscaling_group" "workers" { resource "aws_launch_configuration" "workers" { count = var.create_eks ? local.worker_group_count : 0 - name_prefix = "${aws_eks_cluster.this[count.index].name}-${lookup(var.worker_groups[count.index], "name", count.index)}" + name_prefix = "${aws_eks_cluster.this[0].name}-${lookup(var.worker_groups[count.index], "name", count.index)}" associate_public_ip_address = lookup( var.worker_groups[count.index], "public_ip", @@ -244,14 +244,14 @@ resource "random_pet" "workers" { resource "aws_security_group" "workers" { count = var.worker_create_security_group && var.create_eks ? 1 : 0 - name_prefix = aws_eks_cluster.this[count.index].name + name_prefix = aws_eks_cluster.this[0].name description = "Security group for all nodes in the cluster." vpc_id = var.vpc_id tags = merge( var.tags, { - "Name" = "${aws_eks_cluster.this[count.index].name}-eks_worker_sg" - "kubernetes.io/cluster/${aws_eks_cluster.this[count.index].name}" = "owned" + "Name" = "${aws_eks_cluster.this[0].name}-eks_worker_sg" + "kubernetes.io/cluster/${aws_eks_cluster.this[0].name}" = "owned" }, ) } @@ -313,7 +313,7 @@ resource "aws_security_group_rule" "workers_ingress_cluster_https" { resource "aws_iam_role" "workers" { count = var.manage_worker_iam_resources && var.create_eks ? 1 : 0 - name_prefix = var.workers_role_name != "" ? null : aws_eks_cluster.this[count.index].name + name_prefix = var.workers_role_name != "" ? null : aws_eks_cluster.this[0].name name = var.workers_role_name != "" ? var.workers_role_name : null assume_role_policy = data.aws_iam_policy_document.workers_assume_role_policy.json permissions_boundary = var.permissions_boundary @@ -324,7 +324,7 @@ resource "aws_iam_role" "workers" { resource "aws_iam_instance_profile" "workers" { count = var.manage_worker_iam_resources && var.create_eks ? local.worker_group_count : 0 - name_prefix = aws_eks_cluster.this[count.index].name + name_prefix = aws_eks_cluster.this[0].name role = lookup( var.worker_groups[count.index], "iam_role_id", @@ -366,8 +366,8 @@ resource "aws_iam_role_policy_attachment" "workers_autoscaling" { resource "aws_iam_policy" "worker_autoscaling" { count = var.manage_worker_iam_resources && var.manage_worker_autoscaling_policy && var.create_eks ? 1 : 0 - name_prefix = "eks-worker-autoscaling-${aws_eks_cluster.this[count.index].name}" - description = "EKS worker node autoscaling policy for cluster ${aws_eks_cluster.this[count.index].name}" + name_prefix = "eks-worker-autoscaling-${aws_eks_cluster.this[0].name}" + description = "EKS worker node autoscaling policy for cluster ${aws_eks_cluster.this[0].name}" policy = data.aws_iam_policy_document.worker_autoscaling[0].json path = var.iam_path } diff --git a/workers_launch_template.tf b/workers_launch_template.tf index 8cf3d673..519a2899 100644 --- a/workers_launch_template.tf +++ b/workers_launch_template.tf @@ -6,7 +6,7 @@ resource "aws_autoscaling_group" "workers_launch_template" { "-", compact( [ - aws_eks_cluster.this[count.index].name, + aws_eks_cluster.this[0].name, lookup(var.worker_groups_launch_template[count.index], "name", count.index), lookup(var.worker_groups_launch_template[count.index], "asg_recreate_on_change", local.workers_group_defaults["asg_recreate_on_change"]) ? random_pet.workers_launch_template[count.index].id : "" ] @@ -167,7 +167,7 @@ resource "aws_autoscaling_group" "workers_launch_template" { [ { "key" = "Name" - "value" = "${aws_eks_cluster.this[count.index].name}-${lookup( + "value" = "${aws_eks_cluster.this[0].name}-${lookup( var.worker_groups_launch_template[count.index], "name", count.index, @@ -175,7 +175,7 @@ resource "aws_autoscaling_group" "workers_launch_template" { "propagate_at_launch" = true }, { - "key" = "kubernetes.io/cluster/${aws_eks_cluster.this[count.index].name}" + "key" = "kubernetes.io/cluster/${aws_eks_cluster.this[0].name}" "value" = "owned" "propagate_at_launch" = true }, @@ -189,8 +189,8 @@ resource "aws_autoscaling_group" "workers_launch_template" { "propagate_at_launch" = false }, { - "key" = "k8s.io/cluster-autoscaler/${aws_eks_cluster.this[count.index].name}" - "value" = aws_eks_cluster.this[count.index].name + "key" = "k8s.io/cluster-autoscaler/${aws_eks_cluster.this[0].name}" + "value" = aws_eks_cluster.this[0].name "propagate_at_launch" = false }, { @@ -219,7 +219,7 @@ resource "aws_autoscaling_group" "workers_launch_template" { resource "aws_launch_template" "workers_launch_template" { count = var.create_eks ? (local.worker_group_launch_template_count) : 0 - name_prefix = "${aws_eks_cluster.this[count.index].name}-${lookup( + name_prefix = "${aws_eks_cluster.this[0].name}-${lookup( var.worker_groups_launch_template[count.index], "name", count.index, @@ -364,7 +364,7 @@ resource "aws_launch_template" "workers_launch_template" { tags = merge( { - "Name" = "${aws_eks_cluster.this[count.index].name}-${lookup( + "Name" = "${aws_eks_cluster.this[0].name}-${lookup( var.worker_groups_launch_template[count.index], "name", count.index, @@ -402,7 +402,7 @@ resource "random_pet" "workers_launch_template" { resource "aws_iam_instance_profile" "workers_launch_template" { count = var.manage_worker_iam_resources && var.create_eks ? local.worker_group_launch_template_count : 0 - name_prefix = aws_eks_cluster.this[count.index].name + name_prefix = aws_eks_cluster.this[0].name role = lookup( var.worker_groups_launch_template[count.index], "iam_role_id",