diff --git a/main.tf b/main.tf index 3616f6f..11ee0ee 100644 --- a/main.tf +++ b/main.tf @@ -5,7 +5,7 @@ locals { resource "argocd_application_set" "this" { metadata { name = "${var.project_name}-${var.name}" - namespace = "argo-system" + namespace = var.namespace } spec { @@ -112,10 +112,13 @@ resource "argocd_application_set" "this" { namespace = var.target_namespace_overwrite != "" ? var.target_namespace_overwrite : "{{ if not .namespace_overwrite }}${var.project_name}-{{ ${local.generator_selector} }}{{ else }}${var.project_name}-{{ .namespace_overwrite }}{{ end }}" } sync_policy { - automated { - prune = true - self_heal = true - allow_empty = true + dynamic "automated" { + for_each = var.sync_policy != null ? [var.sync_policy] : [] + content { + prune = var.sync_policy.automated.prune + self_heal = var.sync_policy.automated.self_heal + allow_empty = var.sync_policy.automated.allow_empty + } } managed_namespace_metadata { annotations = merge( diff --git a/variables.tf b/variables.tf index 8b760fc..1703310 100644 --- a/variables.tf +++ b/variables.tf @@ -3,6 +3,12 @@ variable "name" { description = "The name of the application set" } +variable "namespace" { + type = string + description = "The namespace the application set should be deployed to." + default = "argo-system" +} + variable "project_name" { type = string description = "The name of the ArgoCD project to use for this application set. If not set, this application set is special. Special application sets are managed by the platform team and therefore the ArgoCD project reference is handled differently to normal application sets. A major difference is that the ArgoCD project is not statically defined as reference but dynamically via the config directory name." @@ -133,3 +139,13 @@ variable "generator_segment_index_overwrite" { description = "Optional generator setting to override the index path segment during path selection. This option should only be set if generator.git.directories is used. Otherwise it should be left empty as it may affect the behavior. If this option is set in combination with generator.git.directories and your repository contains the cluster folder name in its root directory, this option should be set to 0. In all other cases, this option should reflect the index segment level to the directory corresponding to the cluster name." default = null } + +variable "sync_policy" { + type = object({ + prune = bool + self_heal = bool + allow_empty = bool + }) + description = "ArgoCD sync policy configuration" + default = null +}