-
Notifications
You must be signed in to change notification settings - Fork 0
/
route53.tf
36 lines (29 loc) · 1.1 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
data "aws_route53_zone" "selected" {
count = var.hostname_create ? 1 : 0
name = var.hosted_zone
}
resource "aws_route53_record" "alb_hostname" {
count = var.lb_type == "ALB" && var.hostname_create && length(var.hostnames) != 0 ? length(var.hostnames) : 0
zone_id = data.aws_route53_zone.selected.*.zone_id[0]
name = var.hostnames[count.index]
type = "CNAME"
ttl = "300"
records = aws_lb.alb.*.dns_name
}
resource "aws_route53_record" "nlb_hostname" {
count = var.lb_type == "NLB" && var.hostname_create && length(var.hostnames) != 0 ? length(var.hostnames) : 0
zone_id = data.aws_route53_zone.selected.*.zone_id[0]
name = var.hostnames[count.index]
type = "CNAME"
ttl = "300"
records = aws_lb.nlb.*.dns_name
}
resource "aws_route53_record" "eip_hostname" {
count = var.lb_type == "EIP" && var.hostname_create && length(var.hostnames) != 0 ? length(var.hostnames) : 0
zone_id = data.aws_route53_zone.selected.*.zone_id[0]
name = var.hostnames[count.index]
type = "A"
ttl = "300"
records = aws_eip.default.*.public_ip
depends_on = [aws_eip.default]
}