forked from cytopia/terraform-aws-route53-zone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals.tf
148 lines (144 loc) · 4.33 KB
/
locals.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# -------------------------------------------------------------------------------------------------
# Public root zones
# -------------------------------------------------------------------------------------------------
locals {
# Transforms from:
# ----------------
# var.public_root_zones = [
# {
# name = "example1.tld",
# delegation_set = "deleg-name",
# },
# {
# name = "example2.tld",
# delegation_set = null,
# },
# ]
#
# Transforms into:
# ----------------
# local.public_root_zones = {
# "example1.tld" {
# "name" = "example1.tld"
# "deleg_id" = "N0XXXXXXXXXXXXX"
# "deleg_name" = "deleg-name"
# },
# "example2.tld" {
# "name" = "example2.tld"
# "deleg_id" = null
# "deleg_name" = null
# },
# }
public_root_zones = {
for zone in var.public_root_zones : zone.name => {
name = zone.name
deleg_id = zone.delegation_set != null ? aws_route53_delegation_set.delegation_sets[zone.delegation_set]["id"] : null
deleg_name = zone.delegation_set
}
}
}
# -------------------------------------------------------------------------------------------------
# Public secondary zones
# -------------------------------------------------------------------------------------------------
locals {
# Transforms from:
# ----------------
# var.public_delegated_secondary_zones = [
# {
# name = "intranet.example.tld",
# root = "example.tld",
# nameservers = [],
# ns_ttl = 30,
# delegation_set = "deleg-name",
# },
# {
# name = "private.example.tld",
# root = "example.tld",
# nameservers = ["1,1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"],
# delegation_set = null,
# ns_ttl = 30,
# },
# ]
#
# Transforms into:
# ----------------
# local.public_delegated_secondary_zones = {
# "intranet.example1.tld" {
# "name" = "intranet.example.tld"
# "parent" = "example.tld",
# "deleg_id" = "N0XXXXXXXXXXXXX"
# "deleg_name" = "deleg-name"
# },
# "private.example1.tld" {
# "name" = "private.example.tld"
# "parent" = "example.tld",
# "deleg_id" = null
# "deleg_name" = ""
# },
# }
# local.public_delegated_secondary_default_ns_records = {
# "intranet.example1.tld" {
# "name" = "intranet.example.tld"
# "parent" = "example.tld",
# },
# }
# local.public_delegated_secondary_custom_ns_records = {
# "private.example1.tld" {
# "name" = "private.example.tld"
# "parent" = "example.tld",
# "nameservers" = ["1,1.1.1", "2.2.2.2", "3.3.3.3", "4.4.4.4"],
# "ns_ttl" = 30,
# },
# }
public_delegated_secondary_zones = {
for zone in var.public_delegated_secondary_zones : zone.name => {
name = zone.name
parent = zone.parent
deleg_id = zone.delegation_set != null ? aws_route53_delegation_set.delegation_sets[zone.delegation_set]["id"] : null
deleg_name = zone.delegation_set
}
}
public_delegated_secondary_ns_records = {
for zone in var.public_delegated_secondary_zones : zone.name => {
name = zone.name
parent = zone.parent
ns_ttl = zone.ns_ttl
ns_list = length(zone.ns_list) == 0 ? aws_route53_zone.public_delegated_secondary_zones[zone.name]["name_servers"] : zone.ns_list
}
}
}
# -------------------------------------------------------------------------------------------------
# Private root zones
# -------------------------------------------------------------------------------------------------
locals {
# Transforms from:
# ----------------
# var.private_root_zones = [
# {
# name = "example1.tld",
# vpc_ids = [{"id"="vpc-11111", "region"="eu-central"}],
# },
# {
# name = "example2.tld",
# vpc_ids = [{"id"="vpc-11111", "region"="eu-central"}],
# },
# ]
#
# Transforms into:
# ----------------
# local.private_root_zones = {
# "example1.tld" {
# "name" = "example1.tld"
# vpc_ids = [{"id"="vpc-11111", "region"="eu-central"}],
# },
# "example2.tld" {
# "name" = "example2.tld"
# vpc_ids = [{"id"="vpc-11111", "region"="eu-central"}],
# },
private_root_zones = {
for zone in var.private_root_zones : zone.name => {
name = zone.name
vpc_ids = zone.vpc_ids
}
}
}