Skip to content

Commit

Permalink
AWS vpc-cni custom networking fix (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
nerahou authored Apr 24, 2024
1 parent 88d882b commit 0378e9e
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,24 @@ locals {
}
}

resource "aws_eks_addon" "vpc_cni_addon" {
count = local.handle_aws_vpc_cni ? 1 : 0

cluster_name = aws_eks_cluster.quortex.name
addon_name = "vpc-cni"
addon_version = var.cluster_addons["vpc-cni"].version
configuration_values = try(var.cluster_addons["vpc-cni"].configuration_values, null)
preserve = try(var.cluster_addons["vpc-cni"].preserve, null)
resolve_conflicts_on_update = try(var.cluster_addons["vpc-cni"].resolve_conflicts, "OVERWRITE")
resolve_conflicts_on_create = try(var.cluster_addons["vpc-cni"].resolve_conflicts, "OVERWRITE")
service_account_role_arn = lookup(local.addon_irsa_service_account_arn, "vpc-cni", null)

tags = var.tags
}

# Eks addons
resource "aws_eks_addon" "quortex_addon" {
for_each = { for k, v in var.cluster_addons : k => v }
for_each = { for k, v in var.cluster_addons : k => v if k != "vpc-cni" }

cluster_name = aws_eks_cluster.quortex.name
addon_name = each.key
Expand All @@ -204,6 +219,8 @@ resource "aws_eks_addon" "quortex_addon" {
service_account_role_arn = lookup(local.addon_irsa_service_account_arn, each.key, null)

tags = var.tags

depends_on = [helm_release.eni_configs]
}

# This AWS CLI command will add tags to the ASG created by EKS
Expand Down Expand Up @@ -271,7 +288,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 @@ -282,5 +299,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.vpc_cni_addon]
}

0 comments on commit 0378e9e

Please sign in to comment.