Skip to content

Commit

Permalink
removing count/environments variable dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
yaman committed Sep 3, 2019
1 parent e104f40 commit 9355710
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
resource "kubernetes_config_map" "nginx_configuration" {
count = length(var.environments)
metadata {
name = "nginx-configuration"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}

resource "kubernetes_config_map" "tcp_services" {
count = length(var.environments)
metadata {
name = "tcp-services"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}

resource "kubernetes_config_map" "udp_services" {
count = length(var.environments)

metadata {
name = "udp-services"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}

resource "kubernetes_service_account" "nginx_ingress_serviceaccount" {
count = length(var.environments)

metadata {
name = "nginx-ingress-serviceaccount"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
}
Expand Down Expand Up @@ -72,10 +70,10 @@ resource "kubernetes_cluster_role" "nginx_ingress_clusterrole" {
}

resource "kubernetes_role" "nginx_ingress_role" {
count = length(var.environments)

metadata {
name = "nginx-ingress-role"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
rule {
Expand All @@ -102,16 +100,16 @@ resource "kubernetes_role" "nginx_ingress_role" {
}

resource "kubernetes_role_binding" "nginx_ingress_role_nisa_binding" {
count = length(var.environments)

metadata {
name = "nginx-ingress-role-nisa-binding"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
subject {
kind = "ServiceAccount"
name = "nginx-ingress-serviceaccount"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
Expand All @@ -121,15 +119,15 @@ resource "kubernetes_role_binding" "nginx_ingress_role_nisa_binding" {
}

resource "kubernetes_cluster_role_binding" "nginx_ingress_clusterrole_nisa_binding" {
count = length(var.environments)

metadata {
name = "${var.environments[count.index]}-nginx-ingress-clusterrole-nisa-binding"
name = "${var.namespace}-nginx-ingress-clusterrole-nisa-binding"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
subject {
kind = "ServiceAccount"
name = "nginx-ingress-serviceaccount"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
}
role_ref {
api_group = "rbac.authorization.k8s.io"
Expand All @@ -139,10 +137,10 @@ resource "kubernetes_cluster_role_binding" "nginx_ingress_clusterrole_nisa_bindi
}

resource "kubernetes_deployment" "nginx_ingress_controller" {
count = length(var.environments)

metadata {
name = "nginx-ingress-controller"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
spec {
Expand Down Expand Up @@ -224,10 +222,10 @@ resource "kubernetes_deployment" "nginx_ingress_controller" {
}

resource "kubernetes_service" "ingress_nginx" {
count = length(var.environments)

metadata {
name = "ingress-nginx"
namespace = var.environments[count.index]
namespace = "${var.namespace}"
labels = { "app.kubernetes.io/name" = "ingress-nginx", "app.kubernetes.io/part-of" = "ingress-nginx" }
}
spec {
Expand All @@ -247,3 +245,4 @@ resource "kubernetes_service" "ingress_nginx" {
}
}

version = "0.0.2"

0 comments on commit 9355710

Please sign in to comment.