generated from openziti-test-kitchen/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.tf
79 lines (76 loc) · 2.42 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
terraform {
required_providers {
restapi = {
source = "qrkourier/restapi"
version = "~> 1.23.0"
}
}
}
resource "restapi_object" "ziti_router" {
debug = true
provider = restapi
path = "/edge-routers"
# merge maps - last wins
data = jsonencode(merge(
var.default_router_properties,
var.router_properties,
{name=var.name}
))
}
locals {
edge_advertised_host = var.edge_advertised_host != "" ? var.edge_advertised_host : "${var.name}.${var.namespace}.svc"
}
resource "helm_release" "ziti_router" {
depends_on = [restapi_object.ziti_router]
name = var.name
namespace = var.namespace
repository = "https://openziti.github.io/helm-charts"
chart = var.ziti_charts != "" ? "${var.ziti_charts}/ziti-router" : "ziti-router"
version = "~>0.5"
wait = false # hooks don't run if wait=true!?
values = [yamlencode(merge({
image = {
repository = var.image_repo
tag = var.image_tag
pullPolicy = var.image_pull_policy
}
edge = {
enabled = true
advertisedHost = local.edge_advertised_host
advertisedPort = 443
service = {
enabled = true
type = "ClusterIP"
}
ingress = {
enabled = var.edge_advertised_host != "" ? true : false
ingressClassName = "nginx"
annotations = var.ingress_annotations
}
}
linkListeners = {
transport = {
advertisedHost = var.transport_advertised_host
advertisedPort = 443
service = {
enabled = var.transport_advertised_host != "" ? true : false
type = "ClusterIP"
}
ingress = {
enabled = var.transport_advertised_host != "" ? true : false
ingressClassName = "nginx"
annotations = var.ingress_annotations
}
}
}
persistence = {
storageClass = var.storage_class != "-" ? var.storage_class : ""
}
ctrl = {
endpoint = var.ctrl_endpoint
}
enrollmentJwt = try(jsondecode(restapi_object.ziti_router.api_response).data.enrollmentJwt, "-")
},
var.values
))]
}