-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathacm.tf
47 lines (39 loc) · 1.73 KB
/
acm.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
///////////////////////////////////////////////////[ AWS CERTIFICATE MANAGER ]////////////////////////////////////////////
# # ---------------------------------------------------------------------------------------------------------------------#
# Create ssl certificate for domain and subdomains
# # ---------------------------------------------------------------------------------------------------------------------#
resource "aws_acm_certificate" "default" {
domain_name = "${var.domain}"
subject_alternative_names = ["*.${var.domain}"]
validation_method = "EMAIL"
lifecycle {
create_before_destroy = true
}
tags = {
Name = "${local.project}-${var.domain}-cert"
}
}
resource "aws_acm_certificate" "cloudfront" {
count = data.aws_region.current.name == "us-east-1" ? 0 : 1
provider = aws.useast1
domain_name = "${var.domain}"
subject_alternative_names = ["*.${var.domain}"]
validation_method = "EMAIL"
lifecycle {
create_before_destroy = true
}
tags = {
Name = "${local.project}-${var.domain}-cert"
}
}
# # ---------------------------------------------------------------------------------------------------------------------#
# Validate ssl certificate for domain and subdomains
# # ---------------------------------------------------------------------------------------------------------------------#
resource "aws_acm_certificate_validation" "default" {
certificate_arn = aws_acm_certificate.default.arn
}
resource "aws_acm_certificate_validation" "cloudfront" {
count = data.aws_region.current.name == "us-east-1" ? 0 : 1
provider = aws.useast1
certificate_arn = aws_acm_certificate.cloudfront[0].arn
}