-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
73 lines (73 loc) · 2.78 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
locals {
manifest = {
apiVersion = "argoproj.io/v1alpha1"
kind = "Application"
metadata = {
name = var.name != "" ? var.name : (var.app_source == "helm" ? var.chart : "")
namespace = var.argocd_namespace
labels = local.labels
finalizers = var.cascade_delete == true ? ["resources-finalizer.argocd.argoproj.io"] : []
annotations = var.annotations
}
spec = {
project = var.project
source = {
repoURL = var.repo_url
targetRevision = var.target_revision
chart = var.app_source == "helm" ? var.chart : null
path = var.path
helm = var.app_source == "helm" ? {
releaseName = var.release_name == null ? var.name : var.release_name
parameters = local.helm_parameters
values = var.helm_values
valuesObject = var.helm_values_object
skipCrds = var.skip_crd
fileParameters = var.helm_files_parameters
ignoreMissingValueFiles = var.helm_ignore_missing_values
} : null
}
destination = {
server = var.destination_server_name != "" ? null : var.destination_server
name = var.destination_server_name == "" ? null : var.destination_server_name
namespace = var.namespace
}
ignoreDifferences = var.ignore_differences
syncPolicy = {
automated = {
prune = var.automated_prune
selfHeal = var.automated_self_heal
}
// https://argo-cd.readthedocs.io/en/latest/user-guide/sync-options/
syncOptions = concat(var.sync_options, [
var.sync_option_validate ? "Validate=true" : "Validate=false",
var.sync_option_create_namespace ? "CreateNamespace=true" : "CreateNamespace=false",
var.server_side_apply ? "ServerSideApply=true" : "ServerSideApply=false",
var.apply_out_of_sync_only ? "ApplyOutOfSyncOnly=true" : "ApplyOutOfSyncOnly=false",
var.replace ? "Replace=true" : "Replace=false",
var.fail_on_shared_resource ? "FailOnSharedResource=true" : "FailOnSharedResource=false",
])
retry = {
limit = var.retry_limit
backoff = {
duration = var.retry_backoff_duration
factor = var.retry_backoff_factor
maxDuration = var.retry_backoff_max_duration
}
}
}
}
}
}
resource "kubectl_manifest" "argo_application" {
yaml_body = yamlencode(local.manifest)
wait = var.wait_for_deletion
dynamic "wait_for" {
for_each = var.wait_until_healthy == false ? toset([]) : toset([1])
content {
field {
key = "status.health.status"
value = "Healthy"
}
}
}
}