Skip to content

Commit

Permalink
upgrade cf cf provider
Browse files Browse the repository at this point in the history
  • Loading branch information
lingrino committed Feb 18, 2025
1 parent 641c6e5 commit 634ee86
Show file tree
Hide file tree
Showing 14 changed files with 243 additions and 218 deletions.
18 changes: 11 additions & 7 deletions terraform-modules/zone/gsuite.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
resource "cloudflare_record" "txt_gsuite" {
resource "cloudflare_dns_record" "txt_gsuite" {
count = var.enable_gsuite ? 1 : 0

zone_id = cloudflare_zone.zone.id
name = "@"
name = var.domain
type = "TXT"
ttl = 1
content = "v=spf1 include:_spf.google.com ~all"
}

resource "cloudflare_record" "mx_gsuite_verification" {
resource "cloudflare_dns_record" "mx_gsuite_verification" {
for_each = var.enable_gsuite ? {
0 = { priority = 1, value = "aspmx.l.google.com" }
1 = { priority = 5, value = "alt1.aspmx.l.google.com" }
Expand All @@ -19,24 +20,27 @@ resource "cloudflare_record" "mx_gsuite_verification" {
zone_id = cloudflare_zone.zone.id
name = var.domain
type = "MX"
ttl = 1
priority = each.value["priority"]
content = each.value["value"]
}

resource "cloudflare_record" "txt_gsuite_dkim" {
resource "cloudflare_dns_record" "txt_gsuite_dkim" {
count = var.gsuite_dkim_value != "" ? 1 : 0

zone_id = cloudflare_zone.zone.id
name = "google._domainkey"
name = "google._domainkey.${var.domain}"
type = "TXT"
ttl = 1
content = var.gsuite_dkim_value
}

resource "cloudflare_record" "txt_gsuite_dmarc" {
resource "cloudflare_dns_record" "txt_gsuite_dmarc" {
count = var.gsuite_dkim_value != "" ? 1 : 0

zone_id = cloudflare_zone.zone.id
name = "_dmarc"
name = "_dmarc.${var.domain}"
type = "TXT"
ttl = 1
content = "v=DMARC1; p=reject; sp=reject; adkim=s; aspf=s; pct=100; rua=mailto:[email protected]"
}
5 changes: 3 additions & 2 deletions terraform-modules/zone/site_verification.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
resource "cloudflare_record" "txt_base" {
resource "cloudflare_dns_record" "txt_base" {
for_each = var.google_site_verifications

zone_id = cloudflare_zone.zone.id
name = "@"
name = var.domain
type = "TXT"
ttl = 1
content = each.key
}
9 changes: 7 additions & 2 deletions terraform-modules/zone/zone.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
resource "cloudflare_zone" "zone" {
account_id = var.cloudflare_account_id
zone = var.domain
name = var.domain

account = {
id = var.cloudflare_account_id
}

}

resource "cloudflare_zone_dnssec" "zone" {
zone_id = cloudflare_zone.zone.id
status = "active"
}
32 changes: 16 additions & 16 deletions terraform/cloudflare/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 5 additions & 11 deletions terraform/cloudflare/account.tf
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
resource "cloudflare_account" "account" {
name = "lingrino"
type = "standard"
enforce_twofactor = true
}

resource "cloudflare_account_member" "lingrino" {
account_id = cloudflare_account.account.id
email_address = "[email protected]"
name = "lingrino"
type = "standard"

role_ids = [
"33666b9c79b9a5273fc7344ff42f953d",
]
settings = {
enforce_twofactor = true
}
}
6 changes: 4 additions & 2 deletions terraform/cloudflare/notifications.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ resource "cloudflare_notification_policy" "origin_availability" {
name = "Origin Availability"
description = "a cloudflare origin is detected as down"

email_integration {
id = "[email protected]"
mechanisms = {
email = [{
id = "[email protected]"
}]
}
}
31 changes: 18 additions & 13 deletions terraform/cloudflare/site_lingren_com.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,29 @@ module "zone_lingren_com" {
]
}

resource "cloudflare_record" "lingren_com" {
resource "cloudflare_dns_record" "lingren_com" {
zone_id = module.zone_lingren_com.id
proxied = true
name = "lingren.com"
type = "CNAME"
ttl = 1
content = "lingrino.com" # superseded by below redirect
}

resource "cloudflare_record" "star_lingren_com" {
resource "cloudflare_dns_record" "star_lingren_com" {
zone_id = module.zone_lingren_com.id
proxied = true
name = "*.lingren.com"
type = "CNAME"
ttl = 1
content = "lingrino.com" # superseded by below redirect
}

resource "cloudflare_record" "atproto_lingren_com" {
resource "cloudflare_dns_record" "atproto_lingren_com" {
zone_id = module.zone_lingren_com.id
name = "_atproto.lingren.com"
type = "TXT"
ttl = 1
content = "did=did:plc:k6ylnfky52hxfl7yoxfnbwot"
}

Expand All @@ -45,18 +48,20 @@ resource "cloudflare_ruleset" "redirect_lingren_com_to_lingrino_com" {
kind = "zone"
phase = "http_request_dynamic_redirect"

rules {
action = "redirect"
description = "redirect [*.]lingren.com to lingrino.com"
expression = "true"
rules = [
{
action = "redirect"
description = "redirect [*.]lingren.com to lingrino.com"
expression = "true"

action_parameters {
from_value {
status_code = 301
target_url {
value = "https://lingrino.com"
action_parameters = {
from_value = {
status_code = 301
target_url = {
value = "https://lingrino.com"
}
}
}
}
}
]
}
30 changes: 17 additions & 13 deletions terraform/cloudflare/site_lingren_dev.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ module "zone_lingren_dev" {
]
}

resource "cloudflare_record" "lingren_dev" {
resource "cloudflare_dns_record" "lingren_dev" {
zone_id = module.zone_lingren_dev.id
proxied = true
name = "lingren.dev"
type = "CNAME"
ttl = 1
content = "lingrino.com" # superseded by below redirect
}

resource "cloudflare_record" "star_lingren_dev" {
resource "cloudflare_dns_record" "star_lingren_dev" {
zone_id = module.zone_lingren_dev.id
proxied = true
name = "*.lingren.dev"
type = "CNAME"
ttl = 1
content = "lingrino.com" # superseded by below redirect
}

Expand All @@ -34,18 +36,20 @@ resource "cloudflare_ruleset" "redirect_lingren_dev_to_lingrino_com" {
kind = "zone"
phase = "http_request_dynamic_redirect"

rules {
action = "redirect"
description = "redirect [*.]lingren.dev to lingrino.com"
expression = "true"

action_parameters {
from_value {
status_code = 301
target_url {
value = "https://lingrino.com"
rules = [
{
action = "redirect"
description = "redirect [*.]lingren.dev to lingrino.com"
expression = "true"

action_parameters = {
from_value = {
status_code = 301
target_url = {
value = "https://lingrino.com"
}
}
}
}
}
]
}
30 changes: 17 additions & 13 deletions terraform/cloudflare/site_lingren_org.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ module "zone_lingren_org" {
]
}

resource "cloudflare_record" "lingren_org" {
resource "cloudflare_dns_record" "lingren_org" {
zone_id = module.zone_lingren_org.id
proxied = true
name = "lingren.org"
type = "CNAME"
ttl = 1
content = "lingrino.com" # superseded by below redirect
}

resource "cloudflare_record" "star_lingren_org" {
resource "cloudflare_dns_record" "star_lingren_org" {
zone_id = module.zone_lingren_org.id
proxied = true
name = "*.lingren.org"
type = "CNAME"
ttl = 1
content = "lingrino.com" # superseded by below redirect
}

Expand All @@ -34,18 +36,20 @@ resource "cloudflare_ruleset" "redirect_lingren_org_to_lingrino_com" {
kind = "zone"
phase = "http_request_dynamic_redirect"

rules {
action = "redirect"
description = "redirect [*.]lingren.org to lingrino.com"
expression = "true"

action_parameters {
from_value {
status_code = 301
target_url {
value = "https://lingrino.com"
rules = [
{
action = "redirect"
description = "redirect [*.]lingren.org to lingrino.com"
expression = "true"

action_parameters = {
from_value = {
status_code = 301
target_url = {
value = "https://lingrino.com"
}
}
}
}
}
]
}
Loading

0 comments on commit 634ee86

Please sign in to comment.