Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add mod dependencies #1

Merged
merged 1 commit into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}