-
Notifications
You must be signed in to change notification settings - Fork 0
/
cert-manager.tf
58 lines (53 loc) · 1.44 KB
/
cert-manager.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
module "cert-manager" {
count = var.cert-manager.enabled ? 1 : 0
# source = "git::https://github.com/julienym/myTerraformModules.git//helm?ref=1.0.0"
source = "../myTerraformModules/helm"
name = "cert-manager"
repository = "https://charts.jetstack.io"
namespace = "cert-manager"
chart = "cert-manager"
chart_version = "v1.7.1"
# https://github.com/cert-manager/cert-manager/blob/master/deploy/charts/cert-manager/values.yaml
values_file = "${path.module}/charts/cert-manager/default.yaml"
}
resource "kubectl_manifest" "cloudflare_secret" {
count = var.cert-manager.enabled ? 1 : 0
depends_on = [
module.cert-manager
]
yaml_body = <<YAML
apiVersion: v1
kind: Secret
metadata:
name: cloudflare-api-token-secret
namespace: cert-manager
type: Opaque
data:
api-token: ${base64encode(var.cloudflare.api_token)}
YAML
}
resource "kubectl_manifest" "cloudflare_cluster_issuer" {
count = var.cert-manager.enabled ? 1 : 0
depends_on = [
module.cert-manager,
kubectl_manifest.cloudflare_secret
]
yaml_body = <<YAML
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: cloudflare-issuer
spec:
acme:
email: ${var.acme_email}
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: cloudflare-issuer-account-key
solvers:
- dns01:
cloudflare:
apiTokenSecretRef:
name: cloudflare-api-token-secret
key: api-token
YAML
}