-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathacmpca-certificate.tf
44 lines (35 loc) · 1.56 KB
/
acmpca-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
38
39
40
41
42
43
44
resource "aws_acmpca_certificate" "root_ca_certificate" {
count = var.ca_type == "ROOT" ? 1 : 0
certificate_authority_arn = aws_acmpca_certificate_authority.certificate_authority.arn
certificate_signing_request = aws_acmpca_certificate_authority.certificate_authority.certificate_signing_request
signing_algorithm = var.signing_algorithm
validity {
type = strcontains(var.validity, "year") ? "YEARS" : (
strcontains(var.validity, "month") ? "MONTHS" : (
strcontains(var.validity, "day") ? "DAYS" : null
)
)
value = regex("^(\\d+)", var.validity)[0]
}
template_arn = "arn:aws:acm-pca:::template/RootCACertificate/V1"
}
# Signs Subordinate CA with AWS private CA
resource "aws_acmpca_certificate" "subordinate_ca_certificate" {
count = var.ca_type == "SUBORDINATE" ? (
var.subordinate_ca_configuration != null ? (
var.subordinate_ca_configuration.parent_ca_arn != null ? 1 : 0
) : 0
) : 0
certificate_authority_arn = var.subordinate_ca_configuration.parent_ca_arn
certificate_signing_request = aws_acmpca_certificate_authority.certificate_authority.certificate_signing_request
signing_algorithm = var.signing_algorithm
validity {
type = strcontains(var.validity, "year") ? "YEARS" : (
strcontains(var.validity, "month") ? "MONTHS" : (
strcontains(var.validity, "day") ? "DAYS" : null
)
)
value = regex("^(\\d+)", var.validity)[0]
}
template_arn = "arn:aws:acm-pca:::template/SubordinateCACertificate_PathLen${var.subordinate_ca_configuration.path_length}/V1"
}