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 = "git::git@github.com:AutomationDojo/tf-module-cloudflare.git//modules/pages?ref=v2.0.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 = "git::git@github.com:AutomationDojo/tf-module-cloudflare.git//modules/dns?ref=v2.0.1"
zone_id = var.cloudflare_zone_id
records = [
{
name = "www"
type = "CNAME"
value = "example.com"
ttl = 1
proxied = true
}
]
}module "email" {
source = "git::git@github.com:AutomationDojo/tf-module-cloudflare.git//modules/email?ref=v2.0.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 = "git::git@github.com:AutomationDojo/tf-module-cloudflare.git//modules/r2?ref=v2.0.1"
account_id = var.cloudflare_account_id
buckets = [
{
name = "my-storage-bucket"
location = "eeur"
jurisdiction = "eu"
storage_class = "Standard"
}
]
}module "tunnel" {
source = "git::git@github.com:AutomationDojo/tf-module-cloudflare.git//modules/tunnel?ref=v2.0.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"
}
]
}
}
}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
MIT