-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdns.tf
More file actions
39 lines (33 loc) · 1.04 KB
/
dns.tf
File metadata and controls
39 lines (33 loc) · 1.04 KB
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
data "aws_route53_zone" "root_zone" {
count = var.create_dns ? 1 : 0
name = var.zone_name
}
resource "aws_route53_zone" "workshop_zone" {
count = var.create_dns ? 1 : 0
name = "${var.event_name}.${var.zone_name}"
}
resource "aws_route53_record" "workshop" {
count = var.create_dns ? 1 : 0
zone_id = data.aws_route53_zone.root_zone[0].zone_id
name = aws_route53_zone.workshop_zone[0].name
type = "NS"
ttl = "300"
records = aws_route53_zone.workshop_zone[0].name_servers
}
resource "aws_route53_record" "teams" {
count = var.create_dns ? var.num_teams : 0
zone_id = aws_route53_zone.workshop_zone[0].zone_id
name = "team-${count.index + 1}"
type = "A"
ttl = 300 #5 mins
records = [module.team_servers[count.index].public_ip]
depends_on = [aws_route53_record.hub]
}
resource "aws_route53_record" "db" {
count = var.create_dns ? 1 : 0
zone_id = aws_route53_zone.workshop_zone[0].zone_id
name = "db"
type = "A"
ttl = 300 #5 mins
records = [module.db.public_ip]
}