forked from threeseed/terraform-emr-spark-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcerts.tf
76 lines (62 loc) · 1.69 KB
/
certs.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
resource "random_string" "zeppelin_keystore_password" {
length = 16
special = false
}
resource "tls_private_key" "key" {
algorithm = "RSA"
}
resource "tls_self_signed_cert" "cert" {
key_algorithm = "RSA"
private_key_pem = tls_private_key.key.private_key_pem
validity_period_hours = 87600
allowed_uses = [
"key_encipherment",
"digital_signature",
"server_auth",
]
dns_names = ["*.${var.region}.compute.internal"]
subject {
common_name = "*.${var.region}.compute.internal"
organization = "Company"
province = "State"
country = "US"
}
}
data "archive_file" "certs" {
type = "zip"
output_path = "${var.certs_path}/certs.zip"
source {
content = tls_private_key.key.private_key_pem
filename = "privateKey.pem"
}
source {
content = tls_self_signed_cert.cert.cert_pem
filename = "certificateChain.pem"
}
source {
content = tls_self_signed_cert.cert.cert_pem
filename = "trustedCertificates.pem"
}
}
resource "tls_self_signed_cert" "public_cert" {
key_algorithm = "RSA"
private_key_pem = tls_private_key.key.private_key_pem
validity_period_hours = 87600
allowed_uses = [
"key_encipherment",
"digital_signature",
"server_auth",
]
dns_names = ["*.${var.region}.elb.amazonaws.com"]
subject {
common_name = "*.${var.region}.elb.amazonaws.com"
organization = "Company"
province = "State"
country = "US"
}
}
resource "aws_iam_server_certificate" "public_cert" {
name = "${var.cluster_name}-${var.region}"
certificate_body = tls_self_signed_cert.public_cert.cert_pem
private_key = tls_private_key.key.private_key_pem
}