-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdns.tf
87 lines (70 loc) · 2.34 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
data "http" "my_ip4" {
url = "https://api4.my-ip.io/ip.txt"
}
# If I have IPv6 enabled on my connection, then this will return it, otherwise v4 is returned
data "http" "my_ip6" {
url = "https://api.my-ip.io/ip.txt"
}
### gant.ninja
resource "aws_route53_zone" "main" {
name = "gant.ninja"
}
resource "aws_route53_record" "gant_ninja_verify_bing" {
zone_id = aws_route53_zone.main.zone_id
name = "d5883115e215d14a407ea420207e22e0.rob.gant.ninja"
type = "CNAME"
ttl = "86400"
records = ["verify.bing.com"]
}
# Just let AWS manage NS and SOA records.
### robgant.com
resource "aws_route53_zone" "alt_com" {
name = "robgant.com"
}
# Just let AWS manage NS and SOA records.
# Don't update these if not running on the home network!
resource "aws_route53_record" "home_robgant_com_a" {
count = data.http.my_ip4.response_body != "" ? 1 : 0
zone_id = aws_route53_zone.alt_com.zone_id
name = "home.robgant.com"
type = "A"
ttl = "300"
records = [data.http.my_ip4.response_body]
}
resource "aws_route53_record" "home_robgant_com_aaaa" {
count = length(regexall("^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$", data.http.my_ip6.response_body)) > 0 ? 1 : 0
zone_id = aws_route53_zone.alt_com.zone_id
name = "home.robgant.com"
type = "AAAA"
ttl = "300"
records = [data.http.my_ip6.response_body]
}
### robgant.name
resource "aws_route53_zone" "alt_name" {
name = "robgant.name"
}
# Just let AWS manage NS and SOA records.
resource "aws_route53_record" "robgant_name_txt" {
zone_id = aws_route53_zone.alt_name.zone_id
name = "robgant.name"
type = "TXT"
ttl = "86400"
records = ["google-site-verification=jfV-y--mQ-To_Slx_Ivq3pthtVoEpcycm3aJOMxAyuI"]
}
# Don't update these if not running on the home network!
resource "aws_route53_record" "home_robgant_name_a" {
count = data.http.my_ip4.response_body != "" ? 1 : 0
zone_id = aws_route53_zone.alt_name.zone_id
name = "home.robgant.name"
type = "A"
ttl = "300"
records = [data.http.my_ip4.response_body]
}
resource "aws_route53_record" "home_robgant_name_aaaa" {
count = length(regexall("^(?:[A-F0-9]{1,4}:){7}[A-F0-9]{1,4}$", data.http.my_ip6.response_body)) > 0 ? 1 : 0
zone_id = aws_route53_zone.alt_name.zone_id
name = "home.robgant.name"
type = "AAAA"
ttl = "300"
records = [data.http.my_ip6.response_body]
}