From 4835d55c87216c6152461aa159c3c175a3e7631f Mon Sep 17 00:00:00 2001 From: Alexander Hosking Date: Sun, 29 Dec 2019 01:57:42 -0500 Subject: [PATCH] Conversion to Terroform 12 and Cloudflare 2 Adds home temperatures --- ahoskingit/terraform/dns_ahoskingit.tf | 110 ++++++++++++++----------- 1 file changed, 60 insertions(+), 50 deletions(-) diff --git a/ahoskingit/terraform/dns_ahoskingit.tf b/ahoskingit/terraform/dns_ahoskingit.tf index d574818..15f395b 100644 --- a/ahoskingit/terraform/dns_ahoskingit.tf +++ b/ahoskingit/terraform/dns_ahoskingit.tf @@ -3,27 +3,28 @@ #Setup the domain in route53 resource "cloudflare_zone" "ahoskingit_com" { zone = "ahoskingit.com" + plan = "free" } resource "cloudflare_record" "ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "ahoskingit.com" type = "A" ttl = "1" - value = "${var.site5_ip}" + value = var.site5_ip proxied = "true" } resource "cloudflare_record" "ahoskingit_www" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "www" type = "CNAME" - value = "${cloudflare_record.ahoskingit.name}" + value = "cloudflare_record.ahoskingit.name" proxied = "true" } resource "cloudflare_record" "ahoskingit_influx" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "influx" type = "CNAME" value = "home.ahoskingit.com" @@ -34,12 +35,12 @@ resource "cloudflare_record" "ahoskingit_influx" { # domain = "ahoskingit.com" # name = "*" # type = "A" -# value = "${var.home_ip}" +# value = var.home_ip # proxied = "true" #A records cannot be proxied if wildcard #} resource "cloudflare_record" "ahoskingit_plex" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "plex.ahoskingit.com" type = "CNAME" value = "home.ahoskingit.com" @@ -47,165 +48,174 @@ resource "cloudflare_record" "ahoskingit_plex" { } resource "cloudflare_record" "home_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "home" type = "A" - value = "${var.home_ip}" + value = var.home_ip proxied = "true" } +### Home Subdomains ### +resource "cloudflare_record" "temps_home_ahoskingit" { + zone_id = cloudflare_zone.ahoskingit_com.id + name = "temperature.home" + type = "CNAME" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) + proxied = "true" +} +### END Home Subdomains ### resource "cloudflare_record" "kfa_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "kfa" type = "A" - value = "${var.kfa_ip}" + value = var.kfa_ip } resource "cloudflare_record" "lab_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "lab" type = "CNAME" proxied = true - value = "${cloudflare_record.kfa_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = cloudflare_record.kfa_ahoskingit.value } resource "cloudflare_record" "logs_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "logs" type = "A" proxied = true - value = "${var.home_ip}" + value = var.home_ip } resource "cloudflare_record" "inventory_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "inventory" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } # resource "cloudflare_record" "requests_plex_ahoskingit" { -# domain = "${cloudflare_zone.ahoskingit_com.zone}" +# zone_id = cloudflare_zone.ahoskingit_com # name = "requests.plex" # type = "CNAME" # proxied = true -# value = "${cloudflare_record.home_ahoskingit.name}" +# value = "cloudflare_record.home_ahoskingit.name" # } resource "cloudflare_record" "ns1_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "ns1" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } resource "cloudflare_record" "docs_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "docs" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } resource "cloudflare_record" "cloud_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "cloud" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } resource "cloudflare_record" "goals_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "goals" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } resource "cloudflare_record" "office_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "office" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } resource "cloudflare_record" "support_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "support" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } resource "cloudflare_record" "git_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "git" type = "A" - value = "${var.home_ip}" + value = var.home_ip #proxied = "true" } resource "cloudflare_record" "gitlab_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "gitlab" type = "CNAME" proxied = true - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) } resource "cloudflare_record" "monitors_ahoskingit" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id name = "monitors" type = "CNAME" - value = "${cloudflare_record.home_ahoskingit.name}.${cloudflare_zone.ahoskingit_com.zone}" + value = join(".", [cloudflare_record.home_ahoskingit.name, cloudflare_zone.ahoskingit_com.zone]) proxied = true } # email MX records for DNS resource "cloudflare_record" "ahoskingit_com_mx" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" - name = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id + name = "cloudflare_zone.ahoskingit_com.zone" type = "MX" value = "aspmx.l.google.com" priority = 1 } resource "cloudflare_record" "ahoskingit_com_mx1" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" - name = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id + name = cloudflare_zone.ahoskingit_com.id type = "MX" value = "alt1.aspmx.l.google.com" priority = 5 } resource "cloudflare_record" "ahoskingit_com_mx2" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" - name = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id + name = cloudflare_zone.ahoskingit_com.id type = "MX" value = "alt2.aspmx.l.google.com" priority = 5 } resource "cloudflare_record" "ahoskingit_com_mx3" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" - name = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id + name = cloudflare_zone.ahoskingit_com.id type = "MX" value = "alt3.aspmx.l.google.com" priority = 10 } resource "cloudflare_record" "ahoskingit_com_mx4" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" - name = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id + name = cloudflare_zone.ahoskingit_com.id type = "MX" value = "alt4.aspmx.l.google.com" priority = 10 } resource "cloudflare_record" "ahoskingit_com_txt" { - domain = "${cloudflare_zone.ahoskingit_com.zone}" - name = "${cloudflare_zone.ahoskingit_com.zone}" + zone_id = cloudflare_zone.ahoskingit_com.id + name = cloudflare_zone.ahoskingit_com.id type = "TXT" ttl = 120 value = "google-site-verification=8-QKnBQElI58gnygDWcCzvDGRh31c_bFmNMaSd0fCwE" -} +} \ No newline at end of file