Comprehensive Terraform module for managing Cloudflare resources with modular submodules.
- π Pages - Cloudflare Pages projects management
- π DNS - DNS records management
- π§ Email Routing - Email forwarding and routing rules
- πΎ R2 Storage - R2 object storage buckets management
- π Tunnel - Cloudflare Tunnels for secure origin connectivity
- π Automated Versioning - Semantic release integration
- π Auto-generated Docs - Terraform-docs integration
- pages - Cloudflare Pages projects
- dns - DNS records management
- email - Email routing and forwarding
- r2 - R2 object storage buckets
- tunnel - Cloudflare Tunnels
module "pages" {
source = "AutomationDojo/management/cloudflare//modules/pages"
version = "2.3.1"
account_id = var.cloudflare_account_id
projects = {
my-site = {
name = "my-site"
production_branch = "main"
github_owner = "my-org"
github_repo = "my-repo"
build_command = "npm run build"
destination_dir = "dist"
custom_domain = "example.com"
deployment_configs = {
production = {
environment_variables = {
NODE_VERSION = "22"
}
}
}
}
}
}module "dns" {
source = "AutomationDojo/management/cloudflare//modules/dns"
version = "2.3.1"
zone_id = var.cloudflare_zone_id
records = [
{
name = "www"
type = "CNAME"
value = "example.com"
ttl = 1
proxied = true
}
]
}module "email" {
source = "AutomationDojo/management/cloudflare//modules/email"
version = "2.3.1"
zone_id = var.cloudflare_zone_id
account_id = var.cloudflare_account_id
email_routing = {
enabled = true
addresses = [
{
email = "admin@example.com"
}
]
rules = [
{
name = "Forward contact emails"
enabled = true
priority = 0
matchers = [
{
type = "literal"
field = "to"
value = "contact@yourdomain.com"
}
]
actions = [
{
type = "forward"
value = ["admin@example.com"]
}
]
}
]
}
}module "r2" {
source = "AutomationDojo/management/cloudflare//modules/r2"
version = "2.3.1"
account_id = var.cloudflare_account_id
buckets = [
{
name = "my-storage-bucket"
location = "eeur"
jurisdiction = "eu"
storage_class = "Standard"
}
]
}module "tunnel" {
source = "AutomationDojo/management/cloudflare//modules/tunnel"
version = "2.3.1"
account_id = var.cloudflare_account_id
tunnels = {
my-tunnel = {
name = "my-app-tunnel"
ingress_rules = [
{
hostname = "app.example.com"
service = "http://localhost:8080"
},
{
service = "http_status:404"
}
]
}
}
}Available on the Terraform Registry: AutomationDojo/management/cloudflare
Full documentation is available at: https://automationdojo.github.io/tf-module-cloudflare
To view the documentation locally:
# Install dependencies
pip install -r requirements.txt
# Serve documentation locally
mkdocs serve
# Open http://127.0.0.1:8000 in your browserSee examples directory for complete usage examples.
- Terraform >= 1.0
- Cloudflare Provider ~> 5.0