Skip to content

Commit

Permalink
Merge pull request lablabs#1 from lablabs/DNS_related_rework
Browse files Browse the repository at this point in the history
add mod dependencies
  • Loading branch information
remeq authored Mar 30, 2020
2 parents cceea95 + cf26e97 commit cd92bda
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions iam.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
resource "kubernetes_namespace" "alb_ingress" {
depends_on = [var.mod_dependency]
count = (var.enabled && var.k8s_namespace != "kube-system") ? 1 : 0

metadata {
Expand All @@ -9,6 +10,7 @@ resource "kubernetes_namespace" "alb_ingress" {
### iam ###
# Policy
data "aws_iam_policy_document" "alb_ingress" {
depends_on = [var.mod_dependency]
count = var.enabled ? 1 : 0

statement {
Expand Down Expand Up @@ -141,6 +143,7 @@ data "aws_iam_policy_document" "alb_ingress" {
}

resource "aws_iam_policy" "alb_ingress" {
depends_on = [var.mod_dependency]
count = var.enabled ? 1 : 0
name = "${var.cluster_name}-alb-ingress"
path = "/"
Expand All @@ -151,6 +154,7 @@ resource "aws_iam_policy" "alb_ingress" {

# Role
data "aws_iam_policy_document" "alb_ingress_assume" {
depends_on = [var.mod_dependency]
count = var.enabled ? 1 : 0

statement {
Expand All @@ -175,12 +179,14 @@ data "aws_iam_policy_document" "alb_ingress_assume" {
}

resource "aws_iam_role" "alb_ingress" {
depends_on = [var.mod_dependency]
count = var.enabled ? 1 : 0
name = "${var.cluster_name}-alb-ingress"
assume_role_policy = data.aws_iam_policy_document.alb_ingress_assume[0].json
}

resource "aws_iam_role_policy_attachment" "alb_ingress" {
depends_on = [var.mod_dependency]
count = var.enabled ? 1 : 0
role = aws_iam_role.alb_ingress[0].name
policy_arn = aws_iam_policy.alb_ingress[0].arn
Expand Down
2 changes: 2 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
data "helm_repository" "default" {
depends_on = [var.mod_dependency]
name = var.helm_repo_name
url = var.helm_repo_url
}

resource "helm_release" "alb_ingress" {
depends_on = [var.mod_dependency]
count = var.enabled ? 1 : 0
name = var.helm_release_name
repository = data.helm_repository.default.metadata[0].name
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ variable "k8s_service_account_name" {
default = "aws-alb-ingress-controller"
description = "The k8s alb-ingress service account name"
}

#dependence variable binds all AWS resources allocated by
#this module. Dependent modules reference this variable
variable "mod_dependency" {
default = null
}

0 comments on commit cd92bda

Please sign in to comment.