forked from dareyio/PBL-project-17
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcert.tf
64 lines (54 loc) · 1.85 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# The entire section create a certiface, public zone, and validate the certificate using DNS method
# Create the certificate using a wildcard for all the domains created in oyindamola.gq
resource "aws_acm_certificate" "oyindamola" {
domain_name = "*.oyindamola.gq"
validation_method = "DNS"
}
# calling the hosted zone
data "aws_route53_zone" "oyindamola" {
name = "oyindamola.gq"
private_zone = false
}
# selecting validation method
resource "aws_route53_record" "oyindamola" {
for_each = {
for dvo in aws_acm_certificate.oyindamola.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
}
}
allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = data.aws_route53_zone.oyindamola.zone_id
}
# validate the certificate through DNS method
resource "aws_acm_certificate_validation" "oyindamola" {
certificate_arn = aws_acm_certificate.oyindamola.arn
validation_record_fqdns = [for record in aws_route53_record.oyindamola : record.fqdn]
}
# create records for tooling
resource "aws_route53_record" "tooling" {
zone_id = data.aws_route53_zone.oyindamola.zone_id
name = "tooling.oyindamola.gq"
type = "A"
alias {
name = aws_lb.ext-alb.dns_name
zone_id = aws_lb.ext-alb.zone_id
evaluate_target_health = true
}
}
# create records for wordpress
resource "aws_route53_record" "wordpress" {
zone_id = data.aws_route53_zone.oyindamola.zone_id
name = "wordpress.oyindamola.gq"
type = "A"
alias {
name = aws_lb.ext-alb.dns_name
zone_id = aws_lb.ext-alb.zone_id
evaluate_target_health = true
}
}