Switching to subdomain list and flatcar "trees" spec.
This commit is contained in:
21
main.tf
21
main.tf
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user