-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcerts.tf
46 lines (39 loc) · 1.34 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
# ==============================================================================
# Certificate for SSL and storing in Parameter store for retrieval in other ops
# ==============================================================================
provider "acme" {
server_url = "https://acme-v02.api.letsencrypt.org/directory"
}
resource "tls_private_key" "private_key" {
algorithm = "RSA"
}
resource "acme_registration" "reg" {
account_key_pem = tls_private_key.private_key.private_key_pem
email_address = "[email protected]"
}
resource "acme_certificate" "certificate" {
account_key_pem = acme_registration.reg.account_key_pem
common_name = "examplesite.com"
subject_alternative_names = [
"*.examplesite.com"
]
dns_challenge {
provider = "route53"
}
}
# Save values to aws ssm
resource "aws_ssm_parameter" "certificate" {
name = "/infra/core/certificate"
type = "SecureString"
value = acme_certificate.certificate.certificate_pem
}
resource "aws_ssm_parameter" "certificate_chain" {
name = "/infra/core/certificate_chain"
type = "SecureString"
value = acme_certificate.certificate.issuer_pem
}
resource "aws_ssm_parameter" "cert_private_key" {
name = "/infra/core/cert_private_key"
type = "SecureString"
value = acme_certificate.certificate.private_key_pem
}