-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
91 lines (76 loc) · 1.91 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
provider "kubernetes" {
config_path = "/etc/rancher/k3s/k3s.yaml"
config_context = "default"
}
provider "helm" {
kubernetes {
config_path = "/etc/rancher/k3s/k3s.yaml"
config_context = "default"
}
}
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.20.0"
}
}
backend "s3" {
bucket = "website-blog-terraform"
key = "state/argocd"
region = "eu-central-1"
}
}
### ARGOCD ###
resource "helm_release" "argocd" {
namespace = var.argocd_namespace
create_namespace = true
name = var.argocd_name
repository = var.argocd_repository
chart = var.argocd_chart
version = var.argocd_version
values = [
"${file("files/argocd.yaml")}"
]
force_update = var.argocd_force_update
}
### REPO CREDENTIALS ###
resource "kubernetes_secret" "argocd_repo_credentials" {
depends_on = [helm_release.argocd]
metadata {
name = "rootapp-repo"
namespace = "argocd"
labels = {
"argocd.argoproj.io/secret-type" = "repository"
}
}
type = "Opaque"
data = {
"sshPrivateKey" = var.argocd_credentials_key
"type" = "git"
"url" = var.argocd_credentials_url
"name" = var.argocd_credentials_name
"project" = "default"
}
}
### ROOTAPP ###
resource "helm_release" "rootapp" {
depends_on = [
helm_release.argocd,
kubernetes_secret.argocd_repo_credentials
]
namespace = var.argocd_namespace
name = var.rootapp_name
repository = var.rootapp_repository
chart = var.rootapp_chart
version = var.rootapp_version
values = [
templatefile("${path.module}/templates/rootapp-values.tpl",
{
argocd_namespace = var.argocd_namespace
argocd_credentials_url = var.argocd_credentials_url
rootapp_repo_revision = var.rootapp_repo_revision
rootapp_repo_path = var.rootapp_repo_path
})
]
}