Skip to content

fix(dns): add Cloudflare DNS terraform to restore up2cloud.tech#7

Merged
CesarNog merged 1 commit into
mainfrom
fix/cloudflare-dns-records
May 31, 2026
Merged

fix(dns): add Cloudflare DNS terraform to restore up2cloud.tech#7
CesarNog merged 1 commit into
mainfrom
fix/cloudflare-dns-records

Conversation

@CesarNog
Copy link
Copy Markdown
Collaborator

Root cause

up2cloud.tech has no DNS records. The domain resolves to NXDOMAIN, so browsers can't reach the site even though:

  • GitHub Pages is correctly configured (redirects up2cloud.github.ioup2cloud.tech)
  • Cloudflare Pages project up2cloud-tech is live at up2cloud-tech.pages.dev

What this PR adds

terraform/cloudflare/main.tf — registers the custom domain on Cloudflare Pages and creates the missing DNS records:

Record Type Value Proxied
up2cloud.tech CNAME (flattened) up2cloud-tech.pages.dev
www.up2cloud.tech CNAME up2cloud-tech.pages.dev

CI now validates both Terraform directories.

How to apply (fixes the outage immediately)

cd terraform/cloudflare

# Create terraform.tfvars (never commit this file)
cat > terraform.tfvars <<EOF
cloudflare_api_token = "<token with Zone:DNS:Edit + Account:CF Pages:Edit>"
cloudflare_zone_id   = "<Zone ID from Cloudflare dashboard → up2cloud.tech → Overview>"
EOF

terraform init
terraform plan
terraform apply

After apply, DNS propagates within seconds (Cloudflare) and the site will be back up.

Test plan

  • Run terraform apply with valid credentials
  • Verify https://up2cloud.tech loads the site
  • Verify https://www.up2cloud.tech redirects to apex

https://claude.ai/code/session_01AdacpfB74AC4xNZQeej9fw


Generated by Claude Code

The domain is down because its DNS records are missing. This adds a
Terraform config that:
 - Registers up2cloud.tech and www.up2cloud.tech as custom domains on
   the existing Cloudflare Pages project (up2cloud-tech)
 - Creates proxied CNAME records pointing both to up2cloud-tech.pages.dev
   via Cloudflare CNAME flattening

To apply: cd terraform/cloudflare && terraform init && terraform apply
Required vars: cloudflare_api_token, cloudflare_zone_id
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying up2cloud-tech with  Cloudflare Pages  Cloudflare Pages

Latest commit: ab09777
Status: ✅  Deploy successful!
Preview URL: https://33a6c73e.up2cloud-tech.pages.dev
Branch Preview URL: https://fix-cloudflare-dns-records.up2cloud-tech.pages.dev

View logs

@CesarNog CesarNog temporarily deployed to production-approval May 31, 2026 10:40 — with GitHub Actions Inactive
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a Terraform configuration to set up Cloudflare Pages custom domains and DNS records. However, a critical issue was identified: defining explicit cloudflare_record resources for the apex and www domains will cause terraform apply to fail with a duplicate record error, as Cloudflare Pages automatically creates these DNS records when associating a custom domain.

Comment on lines +58 to +84
# ---------------------------------------------------------------------------
# DNS records
# Cloudflare CNAME flattening makes a CNAME work for the apex domain.
# proxied = true routes traffic through Cloudflare edge (DDoS, WAF, cache).
# ---------------------------------------------------------------------------

resource "cloudflare_record" "apex_cname" {
zone_id = var.cloudflare_zone_id
name = "@"
type = "CNAME"
value = "${local.project_name}.pages.dev"
proxied = true
comment = "Cloudflare Pages — up2cloud.tech"

depends_on = [cloudflare_pages_domain.apex]
}

resource "cloudflare_record" "www_cname" {
zone_id = var.cloudflare_zone_id
name = "www"
type = "CNAME"
value = "${local.project_name}.pages.dev"
proxied = true
comment = "Cloudflare Pages — www.up2cloud.tech"

depends_on = [cloudflare_pages_domain.www]
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

When you associate a custom domain with a Cloudflare Pages project using cloudflare_pages_domain, Cloudflare automatically creates the corresponding DNS CNAME records in your zone (if the zone is managed in the same Cloudflare account).

Because of this automatic behavior, defining explicit cloudflare_record resources for the apex and www domains will cause terraform apply to fail with a Code: 81057 (An identical DNS record already exists) error when it tries to create them.

To resolve this, you should remove the explicit cloudflare_record resources entirely. Cloudflare Pages will handle the DNS record creation and proxying automatically.

@CesarNog CesarNog merged commit 40a9e1d into main May 31, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants