-
Notifications
You must be signed in to change notification settings - Fork 1
/
tls.tf
76 lines (60 loc) · 1.68 KB
/
tls.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
# Generate a private key so you can create a CA cert with it.
resource "tls_private_key" "ca" {
algorithm = "RSA"
rsa_bits = 2048
}
# Create a CA cert with the private key you just generated.
resource "tls_self_signed_cert" "ca" {
private_key_pem = tls_private_key.ca.private_key_pem
subject {
common_name = "ca.vault.jrx.de"
}
validity_period_hours = 720 # 30 days
allowed_uses = [
"cert_signing",
"crl_signing",
]
is_ca_certificate = true
# provisioner "local-exec" {
# command = "echo '${tls_self_signed_cert.ca.cert_pem}' > ./vault-ca.pem"
# }
}
# Generate another private key. This one will be used
# To create the certs on your Vault nodes
resource "tls_private_key" "server" {
algorithm = "RSA"
rsa_bits = 2048
# provisioner "local-exec" {
# command = "echo '${tls_private_key.server.private_key_pem}' > ./vault-key.pem"
# }
}
resource "tls_cert_request" "server" {
private_key_pem = tls_private_key.server.private_key_pem
subject {
common_name = "vault.jrx.de"
}
dns_names = [
var.vault_shared_san,
module.loadbalancer.vault_lb_dns_name,
"localhost",
]
ip_addresses = [
"127.0.0.1",
]
}
resource "tls_locally_signed_cert" "server" {
cert_request_pem = tls_cert_request.server.cert_request_pem
ca_private_key_pem = tls_private_key.ca.private_key_pem
ca_cert_pem = tls_self_signed_cert.ca.cert_pem
validity_period_hours = 720 # 30 days
allowed_uses = [
"client_auth",
"digital_signature",
"key_agreement",
"key_encipherment",
"server_auth",
]
# provisioner "local-exec" {
# command = "echo '${tls_locally_signed_cert.server.cert_pem}' > ./vault-crt.pem"
# }
}