-
Notifications
You must be signed in to change notification settings - Fork 0
/
dns.tf
36 lines (31 loc) · 1.09 KB
/
dns.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
data "aws_route53_zone" "public" {
name = var.domain
private_zone = false
}
resource "aws_acm_certificate" "lb" {
domain_name = var.domain
subject_alternative_names = ["*.${var.domain}"]
validation_method = "DNS"
lifecycle {
create_before_destroy = true
}
}
resource "aws_route53_record" "validation" {
zone_id = data.aws_route53_zone.public.zone_id
name = tolist(aws_acm_certificate.lb.domain_validation_options)[0].resource_record_name
type = tolist(aws_acm_certificate.lb.domain_validation_options)[0].resource_record_type
records = [tolist(aws_acm_certificate.lb.domain_validation_options)[0].resource_record_value]
ttl = "300"
}
resource "aws_acm_certificate_validation" "default" {
certificate_arn = aws_acm_certificate.lb.arn
validation_record_fqdns = [aws_route53_record.validation.fqdn]
}
# route53 record pointing to lb
resource "aws_route53_record" "lb" {
zone_id = data.aws_route53_zone.public.zone_id
name = "challenge.${var.domain}"
type = "CNAME"
records = [aws_lb.web.dns_name]
ttl = "300"
}