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 c0ade6d commit 43632fc
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 26 deletions.
12 changes: 7 additions & 5 deletions aks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ resource "azurerm_federated_identity_credential" "loki" {
module "loki-stack" {
source = "../"

argocd_namespace = var.argocd_namespace
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids
argocd_namespace = var.argocd_namespace
argocd_project = var.argocd_project
destination_cluster = var.destination_cluster
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids

retention = var.retention
ingress = var.ingress
Expand Down
12 changes: 7 additions & 5 deletions eks/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module "loki-stack" {
source = "../"

argocd_namespace = var.argocd_namespace
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids
argocd_namespace = var.argocd_namespace
argocd_project = var.argocd_project
destination_cluster = var.destination_cluster
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids

retention = var.retention
ingress = var.ingress
Expand Down
12 changes: 7 additions & 5 deletions kind/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module "loki-stack" {
source = "../"

argocd_namespace = var.argocd_namespace
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids
argocd_namespace = var.argocd_namespace
argocd_project = var.argocd_project
destination_cluster = var.destination_cluster
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids

retention = var.retention
ingress = var.ingress
Expand Down
14 changes: 8 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,22 @@ resource "htpasswd_password" "loki_password_hash" {
}

resource "argocd_project" "this" {
count = var.argocd_project == null ? 1 : 0

metadata {
name = "loki-stack"
name = var.destination_cluster != "in-cluster" ? "loki-stack-${var.destination_cluster}" : "loki-stack"
namespace = var.argocd_namespace
annotations = {
"devops-stack.io/argocd_namespace" = var.argocd_namespace
}
}

spec {
description = "Loki application project"
description = "Loki application project for cluster ${var.destination_cluster}"
source_repos = ["https://github.com/camptocamp/devops-stack-module-loki-stack.git"]

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

Expand All @@ -47,7 +49,7 @@ data "utils_deep_merge_yaml" "values" {

resource "argocd_application" "this" {
metadata {
name = "loki-stack"
name = var.destination_cluster != "in-cluster" ? "loki-stack-${var.destination_cluster}" : "loki-stack"
namespace = var.argocd_namespace
}

Expand All @@ -59,7 +61,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-loki-stack.git"
Expand All @@ -71,7 +73,7 @@ resource "argocd_application" "this" {
}

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

Expand Down
12 changes: 7 additions & 5 deletions sks/main.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
module "loki-stack" {
source = "../"

argocd_namespace = var.argocd_namespace
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids
argocd_namespace = var.argocd_namespace
argocd_project = var.argocd_project
destination_cluster = var.destination_cluster
target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync
dependency_ids = var.dependency_ids

retention = var.retention
ingress = var.ingress
Expand Down
12 changes: 12 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,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 43632fc

Please sign in to comment.