{
  "id": 23278955,
  "title": "Moving a hand-built Cloudflare account into Terraform without downtime",
  "url": "https://urgent.news/2026/12/03/moving-a-hand-built-cloudflare-account-into-terraform-without-downtime",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-12-03T13:09:19.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/kubmeta/moving-a-hand-built-cloudflare-account-into-terraform-without-downtime-37n9"
  },
  "original_language": null,
  "account": "Moving a Cloudflare account into Terraform without any downtime required careful planning and execution. The process involved utilizing Terraform's S3 backend for state management and generating a Cloudflare API token with specific permissions. The team created a module called \"cloudflare-site\" to handle the configuration of individual zones, including DNS records, tunnels, access policies, header rules, and settings.\n\nTo import the existing Cloudflare resources into Terraform, the team generated import blocks for each resource type, ensuring that the IDs matched the exact format required by the Cloudflare provider. The import process involved fetching the IDs from the Cloudflare API, such as record IDs using GET /zones/zone-id/dns_records. For zone settings, the team adopted the existing settings rather than recreating them, as the API always returns an existing setting and cannot create a new one.\n\nAfter the import, the team verified that the Terraform plan was empty, indicating that the configuration matched the existing Cloudflare account. Any differences observed during the plan review were noted and addressed, such as setting Cloudflare's default values explicitly to avoid false null attributes. Additionally, the team ensured that HSTS settings, rulesets, and header rules were imported and configured correctly, matching the existing configuration in Cloudflare.\n\nBy following this methodical approach and adhering to the rule of maintaining an empty plan after each step, the team successfully migrated their Cloudflare account to Terraform without any service disruptions.",
  "summary": "Most Cloudflare accounts start in the dashboard. It works, but nobody can say why a setting has its value, and every change is a click with no review and no history. Our own account was like that: two zones with DNS records, several Cloudflare Tunnels to a server running n8n, Access applications and a policy in front of them, four response header rules, HSTS, SSL and cache settings. Some of it…",
  "summary_source": "publisher",
  "key_points": [
    "Team used Terraform's S3 backend for state management during migration.",
    "Created \"cloudflare-site\" module to handle zone configuration.",
    "Migrated account without downtime by matching IDs and verifying empty Terraform plan."
  ],
  "editors_take": null,
  "opinion": false,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "outlets_capped": false,
    "also_reported_by": []
  },
  "machine_translated": false,
  "ai_generated": true,
  "disclaimer": "Accounts, briefs, key points, the editor’s take and translations are written by software from other outlets’ reporting and may contain errors. A summary whose summary_source is \"publisher\" is the outlet’s own feed text. Always check the linked original."
}