-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute53.tf
56 lines (53 loc) · 1.74 KB
/
route53.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
data "aws_route53_zone" "zone" {
name = var.domain_name
}
resource "aws_route53_record" "alb_record" {
name = var.app_subdomain_name
type = "A"
zone_id = data.aws_route53_zone.zone.zone_id
alias {
evaluate_target_health = true
name = aws_lb.alb.dns_name
zone_id = aws_lb.alb.zone_id
}
dynamic "failover_routing_policy" {
for_each = var.enable_failover_policy ? { value : "dummy_value" } : {}
content {
type = "PRIMARY"
}
}
health_check_id = var.enable_failover_policy ? var.primary_record_healthcheck_id : null
set_identifier = var.enable_failover_policy ? "primary_${var.app_subdomain_name}" : null
}
resource "aws_route53_record" "secondary_alb_record" {
count = var.enable_failover_policy ? 1 : 0
name = var.app_subdomain_name
type = "A"
zone_id = data.aws_route53_zone.zone.zone_id
alias {
evaluate_target_health = false
name = var.secondary_record_alias_name
zone_id = var.secondary_record_zone_id
}
health_check_id = var.secondary_record_healthcheck_id
set_identifier = "secondary_${var.app_subdomain_name}"
failover_routing_policy {
type = "SECONDARY"
}
}
resource "aws_route53_record" "app_validation" {
for_each = {
for dvo in aws_acm_certificate.app_subdomain.domain_validation_options : dvo.domain_name => {
name = dvo.resource_record_name
record = dvo.resource_record_value
type = dvo.resource_record_type
zone_id = data.aws_route53_zone.zone.zone_id
}
}
allow_overwrite = true
name = each.value.name
records = [each.value.record]
ttl = 60
type = each.value.type
zone_id = each.value.zone_id
}