ingress/terraform/dns.tf
2024-08-23 22:03:47 +02:00

53 lines
1.1 KiB
HCL

data "digitalocean_domain" "ingress" {
name = "ingress.tjo.cloud"
}
resource "digitalocean_record" "public" {
for_each = merge(
{
for key, node in local.nodes_with_address : key => {
node = node.name,
ip = node.public_ipv4,
type = "A",
}
},
{
for key, node in local.nodes_with_address : key => {
node = node.name,
ip = node.public_ipv6,
type = "AAAA",
}
}
)
domain = data.digitalocean_domain.ingress.id
type = each.value.type
name = lower(each.value.node)
value = each.value.ip
ttl = 60
}
resource "digitalocean_record" "internal" {
for_each = merge(
{
for key, node in local.nodes_with_address : key => {
node = node.name,
ip = node.internal_ipv4,
type = "A",
}
},
{
for key, node in local.nodes_with_address : key => {
node = node.name,
ip = node.internal_ipv6,
type = "AAAA",
}
}
)
domain = data.digitalocean_domain.ingress.id
type = each.value.type
name = lower(each.value.node)
value = each.value.ip
ttl = 60
}