-
Notifications
You must be signed in to change notification settings - Fork 0
/
root_zone.tf
52 lines (44 loc) · 1.46 KB
/
root_zone.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
variable "root_zone" {
type = "string"
description = "The root zone to use for Kubernetes deployments."
default = "k8s.example.net"
}
resource "aws_route53_zone" "root_zone" {
name = "${var.root_zone}"
comment = "Kubernetes Root Zone"
force_destroy = true
tags {
Name = "kuberform-root-zone"
Owner = "infrastructure"
Billing = "costcenter"
}
}
resource "aws_route53_record" "region_records" {
count = "${length(var.regions)}"
zone_id = "${aws_route53_zone.root_zone.zone_id}"
name = "${element(var.regions, count.index)}.${var.root_zone}"
type = "NS"
ttl = "86400"
records = ["${aws_route53_delegation_set.kubernetes.name_servers}"]
}
resource "aws_route53_zone" "region_zone" {
count = "${length(var.regions)}"
name = "${element(var.regions, count.index)}.${var.root_zone}"
delegation_set_id = "${aws_route53_delegation_set.kubernetes.id}"
comment = "Kubernetes Region Zone ${upper(element(var.regions, count.index))}"
force_destroy = true
tags {
Name = "kuberform-region-zone-${element(var.regions, count.index)}"
Owner = "infrastructure"
Billing = "costcenter"
}
}
output "root_zone_id" {
value = "${aws_route53_zone.root_zone.zone_id}"
}
output "root_zone_nameservers" {
value = "${aws_route53_zone.root_zone.name_servers}"
}
output "region_zones" {
value = "${zipmap(var.regions, aws_route53_zone.region_zone.*.zone_id)}"
}