-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.tf
101 lines (84 loc) · 2.53 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
resource "null_resource" "dependencies" {
triggers = var.dependency_ids
}
resource "argocd_project" "this" {
count = var.argocd_project == null ? 1 : 0
metadata {
name = var.destination_cluster != "in-cluster" ? "traefik-${var.destination_cluster}" : "traefik"
namespace = "argocd"
}
spec {
description = "Traefik application project for cluster ${var.destination_cluster}"
source_repos = ["https://github.com/camptocamp/devops-stack-module-traefik.git"]
destination {
name = var.destination_cluster
namespace = "traefik"
}
orphaned_resources {
warn = true
}
cluster_resource_whitelist {
group = "*"
kind = "*"
}
}
}
data "utils_deep_merge_yaml" "values" {
input = [for i in concat(local.helm_values, var.helm_values) : yamlencode(i)]
}
resource "argocd_application" "this" {
metadata {
name = var.destination_cluster != "in-cluster" ? "traefik-${var.destination_cluster}" : "traefik"
namespace = "argocd"
labels = merge({
"application" = "traefik"
"cluster" = var.destination_cluster
}, var.argocd_labels)
}
wait = var.app_autosync == { "allow_empty" = tobool(null), "prune" = tobool(null), "self_heal" = tobool(null) } ? false : true
spec {
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-traefik.git"
path = "charts/traefik"
target_revision = var.target_revision
helm {
release_name = "traefik"
values = data.utils_deep_merge_yaml.values.output
}
}
destination {
name = var.destination_cluster
namespace = "traefik"
}
sync_policy {
dynamic "automated" {
for_each = toset(var.app_autosync == { "allow_empty" = tobool(null), "prune" = tobool(null), "self_heal" = tobool(null) } ? [] : [var.app_autosync])
content {
prune = automated.value.prune
self_heal = automated.value.self_heal
allow_empty = automated.value.allow_empty
}
}
retry {
backoff {
duration = "20s"
max_duration = "2m"
factor = "2"
}
limit = "5"
}
sync_options = [
"CreateNamespace=true"
]
}
}
depends_on = [
resource.null_resource.dependencies,
]
}
resource "null_resource" "this" {
depends_on = [
resource.argocd_application.this,
]
}