Skip to content

Commit

Permalink
AWS vpc-cni custom networking fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nerahou committed Apr 22, 2024
1 parent fb53a09 commit dd6de05
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
30 changes: 22 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,6 @@ locals {
}
}

# delays creation of add-ons after aws_eks_cluster
resource "time_sleep" "wait_3_minutes" {
depends_on = [aws_eks_cluster.quortex]

create_duration = "3m"
}

# Eks addons
resource "aws_eks_addon" "quortex_addon" {
Expand Down Expand Up @@ -245,6 +239,26 @@ EOF
}
}

resource "null_resource" "enable_custom_networking" {
count = var.handle_eni_configs ? 1 : 0
provisioner "local-exec" {
command = <<EOF
aws eks update-addon \
--region ${data.aws_region.current.name} \
--cluster-name ${var.cluster_name} \
--addon-name vpc-cni \
--configuration-values '{"env": {"AWS_VPC_K8S_CNI_CUSTOM_NETWORK_CFG": "true"}}' \
--resolve-conflicts "OVERWRITE"
EOF
}

depends_on = [
aws_eks_addon.quortex_addon,
helm_release.eni_configs
]
}

resource "aws_security_group" "remote_access" {
# Create this security group only if remote access is requested
count = var.remote_access_ssh_key != null ? 1 : 0
Expand Down Expand Up @@ -278,7 +292,7 @@ resource "aws_cloudwatch_log_group" "cluster_logs" {
}

resource "helm_release" "eni_configs" {
count = var.handle_eni_configs && try(var.cluster_addons["vpc-cni"].enabled, false) ? 1 : 0
count = var.handle_eni_configs ? 1 : 0
version = "1.0.0"
chart = "empty"
repository = "https://quortex.github.io/helm-charts"
Expand All @@ -289,5 +303,5 @@ resource "helm_release" "eni_configs" {
eniConfigs : jsonencode(local.eni_configs)
})
]
depends_on = [aws_eks_addon.quortex_addon["vpc-cni"]]
depends_on = [aws_eks_addon.quortex_addon]
}
4 changes: 0 additions & 4 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,5 @@ terraform {
source = "hashicorp/tls"
version = ">=3.4.0"
}
time = {
source = "hashicorp/time"
version = ">=0.11.1"
}
}
}

0 comments on commit dd6de05

Please sign in to comment.