diff --git a/aks/main.tf b/aks/main.tf index 8ffd7e64..59891c53 100644 --- a/aks/main.tf +++ b/aks/main.tf @@ -33,6 +33,8 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain argocd_namespace = var.argocd_namespace + argocd_project = var.argocd_project + destination_cluster = var.destination_cluster target_revision = var.target_revision cluster_issuer = var.cluster_issuer namespace = var.namespace diff --git a/eks/main.tf b/eks/main.tf index 21acf2bb..f709d82d 100644 --- a/eks/main.tf +++ b/eks/main.tf @@ -4,6 +4,8 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain argocd_namespace = var.argocd_namespace + argocd_project = var.argocd_project + destination_cluster = var.destination_cluster target_revision = var.target_revision cluster_issuer = var.cluster_issuer namespace = var.namespace diff --git a/kind/main.tf b/kind/main.tf index 21acf2bb..f709d82d 100644 --- a/kind/main.tf +++ b/kind/main.tf @@ -4,6 +4,8 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain argocd_namespace = var.argocd_namespace + argocd_project = var.argocd_project + destination_cluster = var.destination_cluster target_revision = var.target_revision cluster_issuer = var.cluster_issuer namespace = var.namespace diff --git a/main.tf b/main.tf index c7211ba6..9ea14baa 100644 --- a/main.tf +++ b/main.tf @@ -3,8 +3,10 @@ resource "null_resource" "dependencies" { } resource "argocd_project" "this" { + count = var.argocd_project == null ? 1 : 0 + metadata { - name = "thanos" + name = var.destination_cluster != "in-cluster" ? "thanos-${var.destination_cluster}" : "thanos" namespace = var.argocd_namespace annotations = { "devops-stack.io/argocd_namespace" = var.argocd_namespace @@ -12,11 +14,11 @@ resource "argocd_project" "this" { } spec { - description = "Thanos application project" + description = "Thanos application project for cluster ${var.destination_cluster}" source_repos = ["https://github.com/camptocamp/devops-stack-module-thanos.git"] destination { - name = "in-cluster" + name = var.destination_cluster namespace = var.namespace } @@ -43,7 +45,7 @@ data "utils_deep_merge_yaml" "values" { resource "argocd_application" "this" { metadata { - name = "thanos" + name = var.destination_cluster != "in-cluster" ? "thanos-${var.destination_cluster}" : "thanos" namespace = var.argocd_namespace } @@ -55,7 +57,7 @@ resource "argocd_application" "this" { wait = var.app_autosync == { "allow_empty" = tobool(null), "prune" = tobool(null), "self_heal" = tobool(null) } ? false : true spec { - project = argocd_project.this.metadata.0.name + project = var.argocd_project == null ? argocd_project.this[0].metadata.0.name : var.argocd_project source { repo_url = "https://github.com/camptocamp/devops-stack-module-thanos.git" @@ -67,7 +69,7 @@ resource "argocd_application" "this" { } destination { - name = "in-cluster" + name = var.destination_cluster namespace = var.namespace } diff --git a/sks/main.tf b/sks/main.tf index 21acf2bb..f709d82d 100644 --- a/sks/main.tf +++ b/sks/main.tf @@ -4,6 +4,8 @@ module "thanos" { cluster_name = var.cluster_name base_domain = var.base_domain argocd_namespace = var.argocd_namespace + argocd_project = var.argocd_project + destination_cluster = var.destination_cluster target_revision = var.target_revision cluster_issuer = var.cluster_issuer namespace = var.namespace diff --git a/variables.tf b/variables.tf index dc40afd6..f9f088c1 100644 --- a/variables.tf +++ b/variables.tf @@ -18,6 +18,18 @@ variable "argocd_namespace" { default = "argocd" } +variable "argocd_project" { + description = "Name of the Argo CD AppProject where the Application should be created. If not set, the Application will be created in a new AppProject only for this Application." + type = string + default = null +} + +variable "destination_cluster" { + description = "Destination cluster where the application should be deployed." + type = string + default = "in-cluster" +} + variable "target_revision" { description = "Override of target revision of the application chart." type = string