Skip to content

Commit

Permalink
Merge pull request #119 from kbst/eksawsauthfix
Browse files Browse the repository at this point in the history
EKS: Force node_pool to depend on aws-auth configmap
  • Loading branch information
pst authored Aug 6, 2020
2 parents 2566c0d + 6ba7ede commit 59ab383
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions aws/_modules/eks/node_pool.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
module "node_pool" {
providers = {
kubernetes = kubernetes.eks
}

source = "./node_pool"

metadata_labels = var.metadata_labels
Expand All @@ -17,4 +21,10 @@ module "node_pool" {
min_size = var.min_size

disk_size = var.root_device_volume_size

# force node_pool to depend on aws-auth configmap
depends-on-aws-auth = {
name = kubernetes_config_map.current.metadata[0].name
namespace = kubernetes_config_map.current.metadata[0].namespace
}
}
16 changes: 16 additions & 0 deletions aws/_modules/eks/node_pool/main.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
data "kubernetes_config_map" "aws_auth" {
# Force an explicit depends_on, on the configmap
# before creating the node pool
# Otherwise the aws_eks_node_group resource
# creates the configmap leaving TF to error
# out because it already exists

metadata {
name = var.depends-on-aws-auth.name
namespace = var.depends-on-aws-auth.namespace
}
}


resource "aws_eks_node_group" "nodes" {
cluster_name = var.cluster_name
node_group_name = var.node_group_name
Expand All @@ -15,4 +29,6 @@ resource "aws_eks_node_group" "nodes" {

tags = var.eks_metadata_tags
labels = var.metadata_labels

depends_on = [data.kubernetes_config_map.aws_auth]
}
5 changes: 5 additions & 0 deletions aws/_modules/eks/node_pool/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,8 @@ variable "subnet_ids" {
type = list(string)
description = "List of VPC subnet IDs to use for nodes."
}

variable "depends-on-aws-auth" {
type = map(string)
description = "Used as a depends_on shim to first create the aws-auth configmap before creating the node_pool."
}

0 comments on commit 59ab383

Please sign in to comment.