-
Notifications
You must be signed in to change notification settings - Fork 0
/
cert.tf
35 lines (28 loc) · 944 Bytes
/
cert.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
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 = "${var.acme_email}"
}
resource "acme_certificate" "certificate" {
account_key_pem = "${acme_registration.reg.account_key_pem}"
common_name = "api.${var.domain}"
subject_alternative_names = []
dns_challenge {
provider = "route53"
config {
AWS_ACCESS_KEY_ID = "${var.aws_access_key}"
AWS_SECRET_ACCESS_KEY = "${var.aws_secret_key}"
AWS_DEFAULT_REGION = "${var.aws_region}"
}
}
}
resource "aws_iam_server_certificate" "elb_cert" {
name_prefix = "tf-${var.base_name}-cert-"
certificate_body = "${acme_certificate.certificate.certificate_pem}"
private_key = "${acme_certificate.certificate.private_key_pem}"
lifecycle {
create_before_destroy = true
}
}