# CloudFlare Domain Registrar and Terraforming My DNS

15 Oct 2021

For several years now, I’ve been using Namecheap as a domain registrar. They’ve done a good job, and I haven’t had any issues with them, but recently I discovered that CloudFlare started offering domain name registration, and since I have been using them as my DNS provider and as a free CDN for around 10 years now, I decided that it made the most sense to transer in the domain. This also has the added benefit of saving me a little bit of money, as CloudFlare doesn’t charge any more than the actual price that it pays, so instead of being something like $12/year, it’s closer to $8.50. It also includes WHOIS protection out of the box, and since my DNS and nameservers were already on CloudFlare, that was configured automatically. The porting process was quick and easy, and I’m pretty happy with the switch.

While I’ve been using Terraform for years now professionally, I realized that I’ve been managing things by hand more often than not for my hobbyist projects. I decided that since I was in the process of making some changes, I’d attempt to rewrite all my DNS entries for the dylanmtaylor.com zone in CloudFlare into Terraform code using the terraform import functionality and the cloudflare provider. While looking into this, I actually discovered that there is a project for generating HCL code from existing resources for CloudFlare called cf-terraforming. After an evening of playing with this and generating and importing my resources, I decided to sign up on terraform.io with a free account to store the Terraform state. Leveraging terraform.io as a backend means that I don’t have to worry about my state file, as it’s stored in the cloud for me. Originally I was going to leverage GitLab’s CI/CD but for Terraform, using a hosted solution makes a ton of sense and I can store my secrets in their vault for free with write-only access. I use Terraform Cloud’s ability to integrate with a VCS repository so that if I ever want to change my DNS, I just have to make a commit to the repository and click ‘confirm and apply’ in the web interface. The GitLab project with my CloudFlare Terraform code is available publicly in case it’s useful to anyone as reference material.

Dylan Taylor
Software Engineer