Switching to subdomain list and flatcar "trees" spec.

This commit is contained in:
2025-08-14 09:21:38 -07:00
parent 052acf4173
commit 221fccc3d1
6 changed files with 50 additions and 27 deletions

21
main.tf
View File

@@ -74,6 +74,11 @@ variable "domain" {
description = "Root domain to use"
}
variable "subdomains" {
type = list
description = "Subdomains to setup"
}
provider "digitalocean" {
token = var.do_token
}
@@ -97,15 +102,25 @@ resource "digitalocean_reserved_ip" "machine" {
region = digitalocean_droplet.machine.region
}
resource "cloudflare_dns_record" "machine" {
resource "cloudflare_dns_record" "root" {
zone_id = var.cloudflare_zone_id
name = "wg-easy"
name = "@"
content = digitalocean_reserved_ip.machine.ip_address
type = "A"
proxied = false
ttl = 300
}
resource "cloudflare_dns_record" "subdomains" {
for_each = toset(var.subdomains)
zone_id = var.cloudflare_zone_id
name = each.key
content = var.domain
type = "CNAME"
proxied = false
ttl = 300
}
resource "digitalocean_volume" "machine" {
region = var.datacenter
name = "${var.cluster_name}"
@@ -146,6 +161,6 @@ resource "digitalocean_volume_attachment" "machine" {
output "domain-mappings" {
value = {
"wg-easy.${var.domain}" = digitalocean_reserved_ip.machine.ip_address
"${var.domain}" = digitalocean_reserved_ip.machine.ip_address
}
}