Skip to content

Commit

Permalink
feat: add variables to set AppProject and destination cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
lentidas committed Oct 19, 2023
1 parent 88b6d99 commit 1822dcf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 6 deletions.
2 changes: 2 additions & 0 deletions aks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions kind/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@ 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
}
}

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
}

Expand All @@ -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
}

Expand All @@ -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"
Expand All @@ -67,7 +69,7 @@ resource "argocd_application" "this" {
}

destination {
name = "in-cluster"
name = var.destination_cluster
namespace = var.namespace
}

Expand Down
2 changes: 2 additions & 0 deletions sks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1822dcf

Please sign in to comment.