-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
111 lines (94 loc) · 4.14 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
102
103
104
105
106
107
108
109
110
111
################################################################################
# Install ArgoCD
################################################################################
resource "helm_release" "argocd" {
count = var.create && var.argocd_create_install ? 1 : 0
# https://github.com/argoproj/argo-helm/blob/main/charts/argo-cd/Chart.yaml
# (there is no offical helm chart for argocd)
name = try(var.argocd.name, "argo-cd")
description = try(var.argocd.description, "A Helm chart to install the ArgoCD")
namespace = try(var.argocd.namespace, "argocd")
create_namespace = try(var.argocd.create_namespace, true)
chart = try(var.argocd.chart, "argo-cd")
version = try(var.argocd.chart_version, "5.45.0")
repository = try(var.argocd.repository, "https://argoproj.github.io/argo-helm")
values = try(var.argocd.values, [])
timeout = try(var.argocd.timeout, null)
repository_key_file = try(var.argocd.repository_key_file, null)
repository_cert_file = try(var.argocd.repository_cert_file, null)
repository_ca_file = try(var.argocd.repository_ca_file, null)
repository_username = try(var.argocd.repository_username, null)
repository_password = try(var.argocd.repository_password, null)
devel = try(var.argocd.devel, null)
verify = try(var.argocd.verify, null)
keyring = try(var.argocd.keyring, null)
disable_webhooks = try(var.argocd.disable_webhooks, null)
reuse_values = try(var.argocd.reuse_values, null)
reset_values = try(var.argocd.reset_values, null)
force_update = try(var.argocd.force_update, null)
recreate_pods = try(var.argocd.recreate_pods, null)
cleanup_on_fail = try(var.argocd.cleanup_on_fail, null)
max_history = try(var.argocd.max_history, null)
atomic = try(var.argocd.atomic, null)
skip_crds = try(var.argocd.skip_crds, null)
render_subchart_notes = try(var.argocd.render_subchart_notes, null)
disable_openapi_validation = try(var.argocd.disable_openapi_validation, null)
wait = try(var.argocd.wait, true)
wait_for_jobs = try(var.argocd.wait_for_jobs, null)
dependency_update = try(var.argocd.dependency_update, null)
replace = try(var.argocd.replace, null)
lint = try(var.argocd.lint, null)
dynamic "postrender" {
for_each = length(try(var.argocd.postrender, {})) > 0 ? [var.argocd.postrender] : []
content {
binary_path = postrender.value.binary_path
args = try(postrender.value.args, null)
}
}
dynamic "set" {
for_each = try(var.argocd.set, [])
content {
name = set.value.name
value = set.value.value
type = try(set.value.type, null)
}
}
dynamic "set_sensitive" {
for_each = try(var.argocd.set_sensitive, [])
content {
name = set_sensitive.value.name
value = set_sensitive.value.value
type = try(set_sensitive.value.type, null)
}
}
}
resource "kubernetes_secret_v1" "cluster" {
count = var.create && (var.argocd_cluster != null) ? 1 : 0
metadata {
name = var.argocd_cluster.metadata.name
namespace = var.argocd_cluster.metadata.namespace
annotations = var.argocd_cluster.metadata.annotations
labels = var.argocd_cluster.metadata.labels
}
data = var.argocd_cluster.stringData
depends_on = [helm_release.argocd]
}
################################################################################
# Create App of Apps
################################################################################
resource "helm_release" "bootstrap" {
for_each = var.create ? var.argocd_bootstrap_app_of_apps : {}
name = each.key
namespace = "argocd"
repository = "${path.module}/charts"
chart = "raw"
dependency_update = true
version = "2.0.0"
values = [
<<-EOT
resources:
- ${indent(4, each.value)}
EOT
]
depends_on = [resource.kubernetes_secret_v1.cluster]
}