2022-08-18 18:16:44 +02:00
|
|
|
// https://registry.terraform.io/providers/namecheap/namecheap/latest/docs
|
|
|
|
|
2022-08-23 17:16:47 +02:00
|
|
|
variable "caladan-ips" {
|
|
|
|
type = object({
|
|
|
|
v4 = string
|
|
|
|
v6 = string
|
|
|
|
})
|
|
|
|
default = {
|
|
|
|
v4 = "139.162.137.29"
|
|
|
|
v6 = "2a01:7e01::f03c:92ff:fea2:5d7c"
|
|
|
|
}
|
2022-08-18 18:16:44 +02:00
|
|
|
}
|
|
|
|
|
2022-08-23 17:24:51 +02:00
|
|
|
// These are subdomains for services hosted on the host named `caladan`.
|
|
|
|
// Both A and AAAA records should be made for them pointing to caladan's ipv4
|
2022-08-23 17:19:09 +02:00
|
|
|
// and ipv6 respectively
|
2022-08-23 17:07:05 +02:00
|
|
|
variable "caladan-hostnames" {
|
|
|
|
type = set(string)
|
|
|
|
default = ["@"]
|
|
|
|
}
|
|
|
|
|
2022-08-23 17:24:21 +02:00
|
|
|
// These are subdomains for services hosted on the host named `narwhal`.
|
|
|
|
// They are only accessible from my internal network and my internal DNS server
|
|
|
|
// takes care of that.
|
|
|
|
// But I set the public A record to caladan's ipv4 just for renewing their
|
|
|
|
// letsencrypt certificates. No need to set the AAAA record.
|
|
|
|
variable "narwhal-hostnames" {
|
|
|
|
type = set(string)
|
|
|
|
default = ["authelia"]
|
|
|
|
}
|
|
|
|
|
2022-08-18 18:16:44 +02:00
|
|
|
provider "namecheap" {
|
|
|
|
user_name = "gthar"
|
|
|
|
api_user = "gthar"
|
2022-08-23 17:16:47 +02:00
|
|
|
client_ip = var.caladan-ips.v4
|
2022-08-18 18:16:44 +02:00
|
|
|
use_sandbox = false
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "namecheap_domain_records" "monotremata-xyz" {
|
|
|
|
domain = "monotremata.xyz"
|
|
|
|
mode = "MERGE" // maybe eventually move to OVERWRITE
|
|
|
|
|
2022-08-23 17:07:05 +02:00
|
|
|
dynamic "record" {
|
|
|
|
for_each = var.caladan-hostnames
|
|
|
|
content {
|
|
|
|
hostname = record.value
|
|
|
|
type = "A"
|
2022-08-23 17:16:47 +02:00
|
|
|
address = var.caladan-ips.v4
|
2022-08-23 17:07:05 +02:00
|
|
|
}
|
2022-08-18 18:16:44 +02:00
|
|
|
}
|
2022-08-23 17:16:47 +02:00
|
|
|
|
2022-08-23 17:24:21 +02:00
|
|
|
dynamic "record" {
|
|
|
|
for_each = var.narwhal-hostnames
|
|
|
|
content {
|
|
|
|
hostname = record.value
|
|
|
|
type = "A"
|
|
|
|
address = var.caladan-ips.v4
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-23 17:16:47 +02:00
|
|
|
dynamic "record" {
|
|
|
|
for_each = var.caladan-hostnames
|
|
|
|
content {
|
|
|
|
hostname = record.value
|
|
|
|
type = "AAAA"
|
|
|
|
address = var.caladan-ips.v6
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-18 18:16:44 +02:00
|
|
|
}
|