Installation¶
This guide will help you get started with the Cloudflare Terraform Module.
Prerequisites¶
Before using this module, ensure you have:
- Terraform >= 1.0 installed
- Cloudflare Account with API access
Cloudflare API Token¶
You'll need a Cloudflare API token with appropriate permissions:
- Log in to your Cloudflare Dashboard
- Go to My Profile > API Tokens
- Click Create Token
- Choose a template or create a custom token with these permissions:
- Account - Cloudflare Pages: Edit
- Zone - DNS: Edit
- Zone - Email Routing Rules: Edit
Configure Terraform¶
1. Set up the Cloudflare Provider¶
terraform {
required_version = ">= 1.0"
required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "~> 5.0"
}
}
}
provider "cloudflare" {
api_token = var.cloudflare_api_token
}
2. Store API Token Securely¶
Create a terraform.tfvars file (add to .gitignore):
cloudflare_api_token = "your-api-token-here"
cloudflare_account_id = "your-account-id"
cloudflare_zone_id = "your-zone-id"
Or use environment variables:
export CLOUDFLARE_API_TOKEN="your-api-token-here"
export TF_VAR_cloudflare_account_id="your-account-id"
export TF_VAR_cloudflare_zone_id="your-zone-id"
Module Installation¶
The module is available on the Terraform Registry. No separate download is needed - Terraform handles this automatically.
Using Specific Versions¶
It's recommended to pin to a specific version:
module "cloudflare_pages" {
source = "AutomationDojo/management/cloudflare//modules/pages"
version = "2.3.0"
# ... configuration
}
Using Latest¶
For development or testing, you can use a version constraint:
module "cloudflare_pages" {
source = "AutomationDojo/management/cloudflare//modules/pages"
version = "~> 2.3"
# ... configuration
}
Warning
Using a loose version constraint means you may receive updates with breaking changes.
Initialize Terraform¶
After configuring your module sources, initialize Terraform:
This will download the module and all required providers.
Next Steps¶
- Quick Start Guide - Create your first resources
- Modules Overview - Explore available modules
- Examples - See complete configurations