ingress/terraform/dns.tf

67 lines
1.4 KiB
Terraform
Raw Normal View History

2024-08-23 20:03:47 +00:00
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
2024-08-24 10:13:05 +00:00
name = "internal.${lower(each.value.node)}"
2024-08-23 20:03:47 +00:00
value = each.value.ip
ttl = 60
}
2024-08-24 10:13:05 +00:00
resource "digitalocean_record" "srv" {
for_each = local.nodes_with_address
domain = data.digitalocean_domain.ingress.id
type = "SRV"
name = digitalocean_record.internal[each.key].fqdn
value = "_nginx._tcp"
port = 9000
priority = 10
weight = 100
ttl = 60
}