forked from particuleio/terraform-kubernetes-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
kong-crds.tf
28 lines (22 loc) · 1 KB
/
kong-crds.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
locals {
kong_crd_version = "kong-${local.kong.chart_version}"
kong_crds = "https://raw.githubusercontent.com/Kong/charts/${local.kong_crd_version}/charts/kong/crds/custom-resource-definitions.yaml"
kong_crds_apply = local.kong.enabled && local.kong.manage_crds ? [for v in data.kubectl_file_documents.kong_crds.0.documents : {
data : yamldecode(v)
content : v
}
] : null
}
data "http" "kong_crds" {
count = local.kong.enabled && local.kong.manage_crds ? 1 : 0
url = local.kong_crds
}
data "kubectl_file_documents" "kong_crds" {
count = local.kong.enabled && local.kong.manage_crds ? 1 : 0
content = data.http.kong_crds[0].response_body
}
resource "kubectl_manifest" "kong_crds" {
for_each = local.kong.enabled && local.kong.manage_crds ? { for v in local.kong_crds_apply : lower(join("/", compact([v.data.apiVersion, v.data.kind, lookup(v.data.metadata, "namespace", ""), v.data.metadata.name]))) => v.content } : {}
yaml_body = each.value
server_side_apply = true
}