From 19f40b1c179f9d7d0f815738f4eca6f227468223 Mon Sep 17 00:00:00 2001 From: Tim Birkett Date: Wed, 11 Mar 2020 14:12:29 +0000 Subject: [PATCH] fix: Use cluster_name rather than cluster_endpoint for consistency --- main.tf | 4 ++-- modules/aws_auth/README.md | 3 ++- modules/aws_auth/aws_auth.tf | 6 +++++- modules/aws_auth/variables.tf | 4 ++-- modules/worker_groups/README.md | 2 +- modules/worker_groups/variables.tf | 2 +- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/main.tf b/main.tf index 90eccca..90be71c 100644 --- a/main.tf +++ b/main.tf @@ -84,8 +84,8 @@ module "node_groups" { module "aws_auth" { source = "./modules/aws_auth" - cluster_endpoint = module.control_plane.cluster_endpoint - map_instances = concat(module.worker_groups.aws_auth_roles, module.node_groups.aws_auth_roles) + cluster_name = module.control_plane.cluster_id + map_instances = concat(module.worker_groups.aws_auth_roles, module.node_groups.aws_auth_roles) create_eks = var.create_eks manage_aws_auth = var.manage_aws_auth diff --git a/modules/aws_auth/README.md b/modules/aws_auth/README.md index 489a67f..340654b 100644 --- a/modules/aws_auth/README.md +++ b/modules/aws_auth/README.md @@ -5,6 +5,7 @@ | Name | Version | |------|---------| +| aws | >= 2.52.0 | | kubernetes | >= 1.6.2 | | null | >= 2.1 | | template | >= 2.1 | @@ -13,7 +14,7 @@ | Name | Description | Type | Default | Required | |------|-------------|------|---------|:-----:| -| cluster\_endpoint | Endpoint for the EKS cluster. | `string` | n/a | yes | +| cluster\_name | Name of the EKS cluster. | `string` | n/a | yes | | create\_eks | Controls if EKS resources should be created (it affects almost all resources). | `bool` | `true` | no | | manage\_aws\_auth | Whether to apply the aws-auth configmap file. | `bool` | `true` | no | | map\_accounts | Additional AWS account numbers to add to the aws-auth configmap. See examples/basic/variables.tf for example format. | `list(string)` | `[]` | no | diff --git a/modules/aws_auth/aws_auth.tf b/modules/aws_auth/aws_auth.tf index 9069d3f..71a0ca0 100644 --- a/modules/aws_auth/aws_auth.tf +++ b/modules/aws_auth/aws_auth.tf @@ -5,12 +5,16 @@ data "template_file" "map_instances" { vars = var.map_instances[count.index] } +data "aws_eks_cluster" "this" { + name = var.cluster_name +} + resource "null_resource" "wait_for_cluster" { count = var.create_eks && var.manage_aws_auth ? 1 : 0 provisioner "local-exec" { environment = { - ENDPOINT = var.cluster_endpoint + ENDPOINT = data.aws_eks_cluster.this.endpoint } command = var.wait_for_cluster_cmd diff --git a/modules/aws_auth/variables.tf b/modules/aws_auth/variables.tf index 5740c57..615d09e 100644 --- a/modules/aws_auth/variables.tf +++ b/modules/aws_auth/variables.tf @@ -4,8 +4,8 @@ variable "create_eks" { default = true } -variable "cluster_endpoint" { - description = "Endpoint for the EKS cluster." +variable "cluster_name" { + description = "Name of the EKS cluster." type = string } diff --git a/modules/worker_groups/README.md b/modules/worker_groups/README.md index d9f5813..35f87e5 100644 --- a/modules/worker_groups/README.md +++ b/modules/worker_groups/README.md @@ -20,7 +20,7 @@ This submodule is designed for use by both the parent `eks` module and by the us | Name | Description | Type | Default | Required | |------|-------------|------|---------|:-----:| | attach\_worker\_cni\_policy | Whether to attach the Amazon managed `AmazonEKS_CNI_Policy` IAM policy to the default worker groups IAM role. WARNING: If set `false` the permissions must be assigned to the `aws-worker` DaemonSet pods via another method or workers will not be able to join the cluster. | `bool` | `true` | no | -| cluster\_name | Name of parent cluster. | `string` | n/a | yes | +| cluster\_name | Name of the parent EKS cluster. | `string` | n/a | yes | | cluster\_security\_group\_id | If provided, the EKS cluster will be attached to this security group. If not given, a security group will be created with necessary ingress/egress to work with the workers | `string` | n/a | yes | | create\_eks | Controls if EKS resources should be created (it affects almost all resources). | `bool` | `true` | no | | iam\_path | If provided, all IAM roles will be created on this path. | `string` | `"/"` | no | diff --git a/modules/worker_groups/variables.tf b/modules/worker_groups/variables.tf index 843eec4..b487059 100644 --- a/modules/worker_groups/variables.tf +++ b/modules/worker_groups/variables.tf @@ -5,7 +5,7 @@ variable "create_eks" { } variable "cluster_name" { - description = "Name of parent cluster." + description = "Name of the parent EKS cluster." type = string }