diff --git a/README.adoc b/README.adoc index 58d746e..c596aa7 100644 --- a/README.adoc +++ b/README.adoc @@ -121,12 +121,12 @@ The following providers are used by this module: - [[provider_null]] <> (>= 3) +- [[provider_argocd]] <> (>= 5) + - [[provider_utils]] <> (>= 1) - [[provider_aws]] <> -- [[provider_argocd]] <> (>= 5) - === Modules The following Modules are called: @@ -182,13 +182,37 @@ Type: `string` Default: `"cluster"` +==== [[input_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` + +==== [[input_argocd_labels]] <> + +Description: Labels to attach to the Argo CD Application resource. + +Type: `map(string)` + +Default: `{}` + +==== [[input_destination_cluster]] <> + +Description: Destination cluster where the application should be deployed. + +Type: `string` + +Default: `"in-cluster"` + ==== [[input_target_revision]] <> Description: Override of target revision of the application chart. Type: `string` -Default: `"v2.0.0"` +Default: `"v2.2.0"` ==== [[input_helm_values]] <> @@ -328,10 +352,28 @@ Description: ID to pass other modules in order to refer to this module as a depe |n/a |yes +|[[input_argocd_project]] <> +|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. +|`string` +|`null` +|no + +|[[input_argocd_labels]] <> +|Labels to attach to the Argo CD Application resource. +|`map(string)` +|`{}` +|no + +|[[input_destination_cluster]] <> +|Destination cluster where the application should be deployed. +|`string` +|`"in-cluster"` +|no + |[[input_target_revision]] <> |Override of target revision of the application chart. |`string` -|`"v2.0.0"` +|`"v2.2.0"` |no |[[input_helm_values]] <> diff --git a/main.tf b/main.tf index 0afd806..253d83f 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 = "efs-csi-driver" + name = var.destination_cluster != "in-cluster" ? "efs-csi-driver-${var.destination_cluster}" : "efs-csi-driver" namespace = var.argocd_namespace annotations = { "devops-stack.io/argocd_namespace" = var.argocd_namespace @@ -12,11 +14,11 @@ resource "argocd_project" "this" { } spec { - description = "EFS CSI driver application project" + description = "EFS CSI driver application project for cluster ${var.destination_cluster}" source_repos = ["https://github.com/camptocamp/devops-stack-module-efs-csi-driver.git"] destination { - name = "in-cluster" + name = var.destination_cluster namespace = "kube-system" } @@ -94,8 +96,12 @@ module "iam_assumable_role_efs" { resource "argocd_application" "this" { metadata { - name = "efs-csi-driver" + name = var.destination_cluster != "in-cluster" ? "efs-csi-driver-${var.destination_cluster}" : "efs-csi-driver" namespace = var.argocd_namespace + labels = merge({ + "application" = "efs-csi-driver" + "cluster" = var.destination_cluster + }, var.argocd_labels) } timeouts { @@ -106,7 +112,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-efs-csi-driver.git" @@ -118,7 +124,7 @@ resource "argocd_application" "this" { } destination { - name = "in-cluster" + name = var.destination_cluster namespace = "kube-system" } diff --git a/variables.tf b/variables.tf index 0484e84..c3858fb 100644 --- a/variables.tf +++ b/variables.tf @@ -13,6 +13,24 @@ variable "argocd_namespace" { type = string } +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 "argocd_labels" { + description = "Labels to attach to the Argo CD Application resource." + type = map(string) + default = {} +} + +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