This module manages Cloudflare Email Routing functionality including forwarding rules, drop rules, and catch-all configurations.
- Email address verification and routing
- Forwarding rules for email aliases
- Drop rules for unwanted email addresses
- Catch-all rule configuration
- Support for multiple zones
module "email_management" {
source = "./modules/email_management"
environment = "production"
account_id = "your-account-id"
zones = {
"example.com" = {
id = "zone-id-1"
name = "example.com"
}
}
aliasroute2email = [
{
alias = "info"
action = "forward"
email_to_route = "admin@example.com"
zone_key = "example.com"
},
{
alias = "spam"
action = "drop"
email_to_route = ""
zone_key = "example.com"
}
]
catch_all_rule = {
zone_key = "example.com"
catchall_email = "catchall@example.com"
}
}| Name | Description | Type | Required | Default |
|---|---|---|---|---|
| environment | Environment name for resource tagging | string | no | "production" |
| account_id | The account ID to manage resources for | string | yes | - |
| zones | Map of DNS zones | map(object) | yes | - |
| aliasroute2email | List of email routing configurations | list(object) | no | [] |
| catch_all_rule | Catch-all email routing configuration | object | no | null |
| Name | Description |
|---|---|
| routing_addresses | Map of verified email routing addresses |
| routing_rules | Map of all routing rules (forwarding + drop) |
| catch_all_rule | Catch-all rule configuration if enabled |
- Email addresses specified in
email_to_routemust be verified in Cloudflare - Forward action requires a valid
email_to_routevalue - Drop action does not require an
email_to_routevalue - Catch-all rules apply to all unmatched email addresses on the zone
- Set
catchall_emailtonullto configure a drop catch-all rule
Run the module tests with:
terraform test -test-directory=modules/email_management/tests