Skip to content

feat(cloudflare): import email routing destination + catch-all - #11

Merged
hasansezertasan merged 1 commit into
mainfrom
feat/email-routing
Jun 25, 2026
Merged

feat(cloudflare): import email routing destination + catch-all#11
hasansezertasan merged 1 commit into
mainfrom
feat/email-routing

Conversation

@hasansezertasan

Copy link
Copy Markdown
Member

Summary

Brings the existing Cloudflare Email Routing setup for `perish.dev` under Terraform management. Discovered via direct API calls (the cf-terraforming flow we documented in `docs/import.md`); written into a new `terraform/cloudflare/email_routing.tf` file with Terraform 1.5+ `import` blocks.

What's now managed

  • `cloudflare_email_routing_address.primary` — the one verified destination (`hasansezertasan@gmail.com`, verified 2025-03-25).
  • `cloudflare_email_routing_catch_all.this` — the single catch-all rule that forwards every address on `perish.dev` to the primary destination.

What's deliberately NOT here

  • Per-pattern rules (`hello@perish.dev → ...`) — none exist today. The file's header comment notes they go here as `cloudflare_email_routing_rule` resources when needed.
  • Email Routing settings (the zone-level config) — the current HCP Cloudflare token lacks `Email Routing Settings:Read` scope, and the settings have been stable since email was first enabled. If config drift becomes a concern, add the scope + a `cloudflare_email_routing_settings` block.

Prereq (already done before this PR)

  • HCP `cloudflare` workspace token had Email Routing scopes added per `docs/setup.md` "Adding scopes to the Cloudflare token later" (Edit on Zone-Email Routing Rules + Account-Email Routing Addresses).
  • Discovery token + `/tmp/cf_token` flow used to read existing state, per `docs/import.md` "Discovery token". Token will be revoked after merge.

Test plan

  • `terraform fmt` + `terraform validate` pass locally.
  • HCP speculative plan: 2 imports, 0 adds/changes/destroys.
  • After merge + apply: `hasansezertasan@gmail.com` continues receiving forwarded mail (smoke test by sending a test mail to `anything@perish.dev`).

Brings the existing Cloudflare Email Routing setup under Terraform
management:

- cloudflare_email_routing_address.primary — the one verified
  destination (hasansezertasan@gmail.com), kept under management so
  any future destination changes are PR-reviewed.
- cloudflare_email_routing_catch_all.this — the single catch-all
  rule that forwards every address on perish.dev to the primary
  destination.

Per-pattern rules (hello@perish.dev → x, etc.) aren't present today
and aren't declared here. Add as cloudflare_email_routing_rule
resources in this file when needed.

Email Routing settings (the zone-level config object) are NOT
managed — the current Cloudflare token lacks "Email Routing
Settings:Read" scope and the settings have been stable since the
zone's email was first enabled. Add scope + resource if config
drift becomes a concern.

Expected HCP plan: 2 imports, 0 adds/changes/destroys.
@hasansezertasan
hasansezertasan merged commit 9f0e4a7 into main Jun 25, 2026
4 checks passed
@hasansezertasan
hasansezertasan deleted the feat/email-routing branch June 25, 2026 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant