-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdns.tf
40 lines (34 loc) · 1.13 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
37
38
39
#DNS Configuration
#Get already , publicly configured Hosted Zone on Route53 - MUST EXIST
data "aws_route53_zone" "dns" {
provider = aws.region-master
name = var.dns-name
}
#Create record in hosted zone for ACM Certificate Domain verification
resource "aws_route53_record" "cert_validation" {
provider = aws.region-master
for_each = {
for val in aws_acm_certificate.jenkins-lb-https.domain_validation_options : val.domain_name => {
name = val.resource_record_name
record = val.resource_record_value
type = val.resource_record_type
}
}
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = data.aws_route53_zone.dns.zone_id
}
#Create Alias record towards ALB from Route53
resource "aws_route53_record" "jenkins" {
provider = aws.region-master
zone_id = data.aws_route53_zone.dns.zone_id
name = join(".", ["jenkins", data.aws_route53_zone.dns.name])
type = "A"
alias {
name = aws_lb.application-lb.dns_name
zone_id = aws_lb.application-lb.zone_id
evaluate_target_health = true
}
}