Skip to content

Commit

Permalink
Simplify input variables
Browse files Browse the repository at this point in the history
  • Loading branch information
vradicevicds committed Sep 26, 2024
1 parent c6a4e5b commit 22ba8cf
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 48 deletions.
20 changes: 2 additions & 18 deletions eks-addons.tf
Original file line number Diff line number Diff line change
@@ -1,23 +1,7 @@
module "eks_addons" {
source = "./modules/eks_addons"
enable_ingress_nginx = var.ingress_nginx_config.enable
source = "./modules/eks_addons"

ingress_nginx_helm_config = {
namespace = "nginx"
name = "ingress-nginx"
chart = "ingress-nginx"
repository = var.ingress_nginx_config.helm_repository
version = var.ingress_nginx_config.helm_version
description = "The NGINX HelmChart Ingress Controller deployment configuration"
create_namespace = true
dependency_update = true
values = [
templatefile("${path.module}/templates/nginx_values.yaml", {
public_subnets = join(", ", local.public_subnets)
}),
yamlencode(var.ingress_nginx_config.chart_values)
]
}
ingress_nginx_config = merge(var.ingress_nginx_config, { subnets_ids = local.public_subnets })

depends_on = [module.eks.eks_cluster_arn]
}
31 changes: 18 additions & 13 deletions modules/eks_addons/ingress-nginx.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
resource "kubernetes_namespace_v1" "ingress_nginx" {
count = try(var.ingress_nginx_helm_config.create_namespace, true) && var.ingress_nginx_helm_config.namespace != "kube-system" && var.enable_ingress_nginx ? 1 : 0
count = var.ingress_nginx_config.enable ? 1 : 0

metadata {
name = var.ingress_nginx_helm_config.namespace
name = "nginx"
}
}

resource "helm_release" "ingress_nginx" {
count = var.enable_ingress_nginx ? 1 : 0
count = var.ingress_nginx_config.enable ? 1 : 0

namespace = var.ingress_nginx_helm_config.namespace
name = var.ingress_nginx_helm_config.name
chart = var.ingress_nginx_helm_config.chart
repository = var.ingress_nginx_helm_config.repository
version = var.ingress_nginx_helm_config.version
description = var.ingress_nginx_helm_config.description
create_namespace = var.ingress_nginx_helm_config.create_namespace
dependency_update = var.ingress_nginx_helm_config.dependency_update
values = var.ingress_nginx_helm_config.values
timeout = 1200
namespace = "nginx"
name = "ingress-nginx"
chart = "ingress-nginx"
repository = var.ingress_nginx_config.helm_repository
version = var.ingress_nginx_config.helm_version
description = "The NGINX HelmChart Ingress Controller deployment configuration"
create_namespace = true
dependency_update = true
values = [
templatefile("${path.module}/templates/nginx_values.yaml", {
public_subnets = join(", ", var.ingress_nginx_config.subnets_ids)
}),
yamlencode(var.ingress_nginx_config.chart_values)
]
timeout = 1200
}
File renamed without changes.
24 changes: 7 additions & 17 deletions modules/eks_addons/variables.tf
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
variable "enable_ingress_nginx" {
description = "Enable Ingress Nginx helm release creation"
type = bool
default = false
}

variable "ingress_nginx_helm_config" {
description = "Helm Configuration for Ingress Nginx"
variable "ingress_nginx_config" {
description = "Ingress Nginx configuration"
type = object({
namespace = string
name = string
chart = string
repository = string
version = string
description = string
create_namespace = bool
dependency_update = bool
values = list(string)
enable = bool
helm_repository = string
helm_version = string
chart_values = map(any)
subnets_ids = list(string)
})
}

0 comments on commit 22ba8cf

Please sign in to comment.