-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathharmonize.tf
63 lines (55 loc) · 1.95 KB
/
harmonize.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
resource "kubernetes_secret" "repository_secret" {
metadata {
name = "metaco-registry"
namespace = var.namespace
}
depends_on = [resource.kubernetes_namespace_v1.harmonize]
type = "kubernetes.io/dockerconfigjson"
data = {
".dockerconfigjson" = jsonencode({
auths = {
"${var.registry_server}" = {
"username" = var.registry_id
"password" = var.registry_password
"email" = var.registry_email
"auth" = base64encode("${var.registry_id}:${var.registry_password}")
}
}
})
}
}
resource "random_string" "clientSecret" {
length = 16
special = true
}
resource "helm_release" "harmonize" {
name = "hmz"
#repository = "https://charts.bitnami.com/bitnami"
chart = "../harmonize-helm/harmonize"
namespace = var.namespace
depends_on = [resource.kubernetes_namespace_v1.harmonize]
# Maximum timeout in secs
timeout = 600
values = [
for template in var.harmonize_helm_templates: templatefile(
template.path,
merge(
{
db_password = local.db_password
clientSecret = resource.random_string.clientSecret.result
harmonize_host = var.endpoints.frontend
harmonize_frontend = var.endpoints.frontend
harmonize_api = var.endpoints.api
harmonize_auth = var.endpoints.auth
harmonize_use_tls = var.use_tls
harmonize_notary_protocol = var.notary_protocol
ingress_classname = var.ingress_classname
},
template.vars
)
)
]
}
output "BEARER_TOKEN" {
value="$(curl --location --request POST http://${var.endpoints.auth}/token --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id=${var.harmonize_helm_templates[0].vars.clientId}' --data-urlencode 'client_secret=${resource.random_string.clientSecret.result}' | jq -r '.access_token')"
}