117 lines
3.1 KiB
HCL
117 lines
3.1 KiB
HCL
#Terraform and its management of DNS in Cloudflare
|
|
|
|
resource "cloudflare_zone" "ahosking_com" {
|
|
zone = "ahosking.com"
|
|
plan = "free"
|
|
}
|
|
|
|
resource "cloudflare_record" "ahosking" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = "ahosking.com"
|
|
type = "A"
|
|
ttl = "1"
|
|
value = var.site5_ip
|
|
}
|
|
|
|
resource "cloudflare_record" "ahosking_wildcard" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = "*.ahosking.com"
|
|
type = "A"
|
|
ttl = "1"
|
|
value = var.home_ip
|
|
}
|
|
|
|
resource "cloudflare_record" "ahosking_www" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = "www.ahosking.com"
|
|
type = "CNAME"
|
|
ttl = "1"
|
|
value = cloudflare_record.ahosking.name
|
|
proxied = "true"
|
|
}
|
|
|
|
resource "cloudflare_record" "ahosking_home" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = "home"
|
|
type = "A"
|
|
ttl = "1"
|
|
value = var.home_ip
|
|
}
|
|
|
|
resource "cloudflare_record" "ahosking_cnames" {
|
|
for_each = toset(var.ahosking_com_cnames)
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = each.key
|
|
type = "CNAME"
|
|
ttl = "1"
|
|
value = join(".", [cloudflare_record.ahosking_home.name, cloudflare_zone.ahosking_com.zone])
|
|
proxied = true
|
|
}
|
|
|
|
resource "cloudflare_record" "ahosking_food" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = "food"
|
|
type = "CNAME"
|
|
ttl = "1"
|
|
proxied = true
|
|
value = join(".", [cloudflare_record.ahosking_home.name, cloudflare_zone.ahosking_com.zone])
|
|
}
|
|
|
|
resource "cloudflare_record" "ahosking_recipes" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = "recipes"
|
|
type = "CNAME"
|
|
ttl = "1"
|
|
proxied = true
|
|
value = join(".", [cloudflare_record.ahosking_home.name, cloudflare_zone.ahosking_com.zone])
|
|
}
|
|
|
|
# email MX value for DNS
|
|
resource "cloudflare_record" "ahosking_mx" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = cloudflare_zone.ahosking_com.zone
|
|
type = "MX"
|
|
ttl = "60"
|
|
value = "aspmx.l.google.com"
|
|
priority = 1
|
|
}
|
|
resource "cloudflare_record" "ahosking_mx1" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = cloudflare_zone.ahosking_com.zone
|
|
type = "MX"
|
|
ttl = "60"
|
|
value = "alt1.aspmx.l.google.com"
|
|
priority = 5
|
|
}
|
|
resource "cloudflare_record" "ahosking_mx2" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = cloudflare_zone.ahosking_com.zone
|
|
type = "MX"
|
|
ttl = "60"
|
|
value = "alt2.aspmx.l.google.com"
|
|
priority = 5
|
|
}
|
|
resource "cloudflare_record" "ahosking_mx3" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = cloudflare_zone.ahosking_com.zone
|
|
type = "MX"
|
|
ttl = "60"
|
|
value = "alt3.aspmx.l.google.com"
|
|
priority = 10
|
|
}
|
|
resource "cloudflare_record" "ahosking_mx4" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = cloudflare_zone.ahosking_com.zone
|
|
type = "MX"
|
|
ttl = "60"
|
|
value = "alt4.aspmx.l.google.com"
|
|
priority = 10
|
|
}
|
|
resource "cloudflare_record" "ahosking_txt" {
|
|
zone_id = cloudflare_zone.ahosking_com.id
|
|
name = cloudflare_zone.ahosking_com.zone
|
|
type = "TXT"
|
|
ttl = 60
|
|
value = "google-site-verification=8-QKnBQElI58gnygDWcCzvDGRh31c_bFmNMaSd0fCwE"
|
|
}
|