forked from AymenSegni/terraform-helm-linkerd2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
anchor-cert.tf
69 lines (55 loc) · 1.66 KB
/
anchor-cert.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
// Create trusted Anchor Certificate
locals {
cert_domains = [
var.cluster_dns_name,
"*.${var.cluster_dns_name}",
"*.cluster.local"
]
}
resource "tls_private_key" "trustanchor_key" {
count = var.external_trustanchor ? 0 : 1
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
resource "tls_self_signed_cert" "trustanchor_cert" {
count = var.external_trustanchor ? 0 : 1
private_key_pem = tls_private_key.trustanchor_key[0].private_key_pem
validity_period_hours = 87600
is_ca_certificate = true
uris = local.cert_domains
dns_names = local.cert_domains
subject {
common_name = "root.linkerd.${var.cluster_dns_name}"
}
allowed_uses = [
"crl_signing",
"cert_signing",
"server_auth",
"client_auth"
]
}
resource "tls_private_key" "issuer_key" {
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
resource "tls_cert_request" "issuer_req" {
private_key_pem = tls_private_key.issuer_key.private_key_pem
uris = local.cert_domains
dns_names = local.cert_domains
subject {
common_name = "identity.linkerd.${var.cluster_dns_name}"
}
}
resource "tls_locally_signed_cert" "issuer_cert" {
cert_request_pem = tls_cert_request.issuer_req.cert_request_pem
ca_private_key_pem = var.external_trustanchor ? var.trustanchor_key.private_key_pem : tls_private_key.trustanchor_key[0].private_key_pem
ca_cert_pem = var.external_trustanchor ? var.trustanchor_cert.cert_pem : tls_self_signed_cert.trustanchor_cert[0].cert_pem
validity_period_hours = 8760
is_ca_certificate = true
allowed_uses = [
"crl_signing",
"cert_signing",
"server_auth",
"client_auth"
]
}