forked from hashicorp/microservices-architecture-on-aws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tls.tf
63 lines (50 loc) · 1.4 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
# Root Certificate Authority
resource "tls_private_key" "ca_key" {
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
# Root Public Certificate
resource "tls_self_signed_cert" "ca_cert" {
private_key_pem = tls_private_key.ca_key.private_key_pem
is_ca_certificate = true
subject {
common_name = "Consul Agent CA"
organization = "HashiCorp Inc."
}
validity_period_hours = 8760
allowed_uses = [
"cert_signing",
"key_encipherment",
"digital_signature"
]
}
# Consul Server Certs
resource "tls_private_key" "consul_server_key" {
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
## Consul Server Cert
resource "tls_cert_request" "consul_server_cert" {
private_key_pem = tls_private_key.consul_server_key.private_key_pem
subject {
common_name = "server.${var.consul_dc1_name}.consul"
organization = "HashiCorp Inc."
}
dns_names = [
"server.dc1.consul",
"localhost"
]
# ip_addresses = var.consul_server_private_ips
ip_addresses = local.server_private_ips
}
## Consul Server Signed Public Certificate
resource "tls_locally_signed_cert" "consul_server_signed_cert" {
cert_request_pem = tls_cert_request.consul_server_cert.cert_request_pem
ca_private_key_pem = tls_private_key.ca_key.private_key_pem
ca_cert_pem = tls_self_signed_cert.ca_cert.cert_pem
allowed_uses = [
"digital_signature",
"key_encipherment"
]
validity_period_hours = 8760
}