By using this site, you agree to the Privacy Policy and Terms of Use.
Accept
World of SoftwareWorld of SoftwareWorld of Software
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Search
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
Reading: Set It and Forget It: Back Up Cloudflare Resources with cf-terraforming | HackerNoon
Share
Sign In
Notification Show More
Font ResizerAa
World of SoftwareWorld of Software
Font ResizerAa
  • Software
  • Mobile
  • Computing
  • Gadget
  • Gaming
  • Videos
Search
  • News
  • Software
  • Mobile
  • Computing
  • Gaming
  • Videos
  • More
    • Gadget
    • Web Stories
    • Trending
    • Press Release
Have an existing account? Sign In
Follow US
  • Privacy
  • Terms
  • Advertise
  • Contact
Copyright © All Rights Reserved. World of Software.
World of Software > Computing > Set It and Forget It: Back Up Cloudflare Resources with cf-terraforming | HackerNoon
Computing

Set It and Forget It: Back Up Cloudflare Resources with cf-terraforming | HackerNoon

News Room
Last updated: 2025/07/11 at 4:43 PM
News Room Published 11 July 2025
Share
SHARE

In this guide, I’ll show how I used cf-terraforming to import Cloudflare resources into Terraform code.

Important note: In the current iteration, I use Terraform primarily as a backup storage mechanism for Cloudflare resources. Management and modifications will continue to be performed manually via the Cloudflare Dashboard, as this approach is generally faster and more efficient.

Setting up access to Cloudflare

Before using Terraform with Cloudflare, users need to configure the appropriate environment variables.

Using an API key

If authenticating through an API Key, export the following environment variables:

export CLOUDFLARE_API_KEY=<EXAMPLE_KEY>
export CLOUDFLARE_EMAIL=<EXAMPLE_EMAIL>

Using an API token

Alternatively, authentication can be done with an API Token by exporting only this variable:

export CLOUDFLARE_API_TOKEN=<EXAMPLE_TOKEN>

Cloudflare’s API Token authentication is flexible but requires complex configuration. To simplify the process, we recommend using an API Key associated with a user account. However, use it with caution, as the API Key grants full access to all Cloudflare actions.

To find the Global API Key or to create an API Token, visit Cloudflare API Tokens.

Using cf-terraforming

Cloudflare provides an official tool, cf-terraforming, which can generate Terraform configuration and state from existing resources. This is the recommended approach for automating the import process.

  • Tested on cf-terraforming version 0.23.3.
  • Not all resources are supported by cf-terraforming. Find the list of supported resources here.
  • Be aware that after updating the Cloudflare Terraform provider to version 5.x.x or higher, resource definitions may change.

Step-by-step guide: Importing with cf-terraforming cf-terraforming

1. Initialize the Terraform provider:

To use this tool, initialize the provider. Create a temporary file, e.g., providers.tf, with the following configuration:

terraform {
  required_providers {
    cloudflare = {
      source  = "cloudflare/cloudflare"
      version = "4.43.0"
    }
  }
}

provider "cloudflare" {}

Then, initialize Terraform:

terraform init

2. Install cf-terraforming:

brew install cloudflare/cloudflare/cf-terraforming

Or download the release from the GitHub repository.

3. Generate Terraform resource configuration (e.g., for a DNS record):

cf-terraforming generate --resource-type cloudflare_record --zone <ZONE_ID> > generate.tf

Example output:

resource "cloudflare_record" "terraform_managed_resource_<RESOURCE_ID>" {
  content = "EXAMPLE_CONTENT"
  name    = "EXAMPLE_NAME"
  proxied = false
  ttl     = 1
  type    = "TXT"
  zone_id = "<ZONE_ID>"
}

4. Generate Terraform import configuration:

cf-terraforming import --resource-type cloudflare_record --zone <ZONE_ID> --modern-import-block > import.tf

Example output:

import {
  to = cloudflare_record.terraform_managed_resource_<RESOURCE_ID>
  id = "<ZONE_ID>/<RESOURCE_ID>"
}

5 Apply Terraform configuration:

terraform apply

Key considerations

A crucial aspect of using cf-terraforming is distinguishing between account-level and zone-level resources. Before using cf-terraforming, refer to the supported resources documentation to understand the resource scope.

To streamline the import process, automate cf-terraforming by using a loop to process multiple ZONE_ID values at once.

Important notes

  • In this context of using Terraform, the primary goal is backup storage rather than direct resource management.
  • If you have a large number of resources, the generated code may become extensive, making navigation and maintenance difficult.
  • To keep the Terraform state manageable, consider structuring resources into logical modules instead of creating a single monolithic state.
  • We recommend not modifying the automatically generated code. Instead, make changes in the Cloudflare Dashboard and re-import the resources as needed.

By following this approach, you can efficiently back up Cloudflare resources while maintaining a clear and manageable Terraform state.

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Twitter Email Print
Share
What do you think?
Love0
Sad0
Happy0
Sleepy0
Angry0
Dead0
Wink0
Previous Article Illegal streaming kingpin who made £1m from sites showing Sky Sports is jailed
Next Article LGND raises $9M to help AI models analyze geospatial data – News
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Stay Connected

248.1k Like
69.1k Follow
134k Pin
54.3k Follow

Latest News

FBI Seizes Sites That Offered Pirated Nintendo, PlayStation Games
News
The newest Nest Learning Thermostat is on sale for Prime Day.
News
Amazon devices deals typically end right when Prime Day does. Shop our top picks while you still can.
News
July 11, 2025 – Apple’s plans for new Macs, iPads, and more
News

You Might also Like

Computing

Annihilation vs. VBF: The Dynamic Interplay for New Physics Discovery at Muon Colliders | HackerNoon

7 Min Read
Computing

Six Orders of Magnitude: Muon Colliders’ Unrivaled Signal-to-Background | HackerNoon

7 Min Read
Computing

Yandex Releases Massive Dataset to Help AI Understand What You Really Like | HackerNoon

10 Min Read
Computing

Muon Colliders: The Era of Electroweak Gauge Boson Collisions | HackerNoon

9 Min Read
//

World of Software is your one-stop website for the latest tech news and updates, follow us now to get the news that matters to you.

Quick Link

  • Privacy Policy
  • Terms of use
  • Advertise
  • Contact

Topics

  • Computing
  • Software
  • Press Release
  • Trending

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

World of SoftwareWorld of Software
Follow US
Copyright © All Rights Reserved. World of Software.
Welcome Back!

Sign in to your account

Lost your password?