-
Notifications
You must be signed in to change notification settings - Fork 1
/
certificate.tf
37 lines (28 loc) · 1.02 KB
/
certificate.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
# certificate generation is optional, only used if var isn't passed
resource "tls_private_key" "keycloak-pk" {
# only create this resource if acm_certificate_arn is null
count = var.acm_certificate_arn == null ? 1 : 0
algorithm = "RSA"
}
resource "tls_self_signed_cert" "keycloak-certificate-body" {
# only create this resource if acm_certificate_arn is null
count = var.acm_certificate_arn == null ? 1 : 0
private_key_pem = join("", tls_private_key.keycloak-pk.*.private_key_pem)
subject {
common_name = var.acm_hostname
organization = var.organization
}
validity_period_hours = 8760
allowed_uses = [
"key_encipherment",
"digital_signature",
"server_auth"
]
}
resource "aws_acm_certificate" "keycloak-certificate" {
# only create this resource if acm_certificate_arn is null
count = var.acm_certificate_arn == null ? 1 : 0
private_key = tls_private_key.keycloak-pk.*.private_key_pem
certificate_body = tls_self_signed_cert.keycloak-certificate-body.*.cert_pem
tags = var.tags
}