Skip to content

feat(cloudflare): manage tunnel routes, DNS and Access with OpenTofu - #3138

Merged
MichielMak merged 4 commits into
mainfrom
cloudflare-iac-tofu
Oct 24, 2026
Merged

MichielMak merged 4 commits into
mainfrom
cloudflare-iac-tofu

Conversation

@michiel-claude

@michiel-claude michiel-claude Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Moves the Cloudflare Tunnel config out of the dashboard and into cloudflare/, managed by OpenTofu.

What's in it

  • cloudflare/tunnel.tf: the tunnel's published applications and their CNAMEs. Public hosts are a plain list (public_hosts); webhook-only hosts have a path regex (webhook_routes).
  • All public hosts now go to https://traefik:443 instead of https://192.168.178.4:443. Each route sends its own hostname as SNI (origin_server_name), which auth already needed. makstra.xyz is dropped.
  • cloudflare/access.tf: the Access apps for arl, spotizerr and deemix, and the reusable "Allow users" policy (the Authentik users group).
  • Deemix had an app-scoped policy that also allowed one external email. That becomes a reusable "Allow guests" policy. Its addresses come from the ACCESS_GUEST_EMAILS secret (a JSON list), because this repo and its Actions logs are public.
  • cloudflare/imports.tf: import blocks for everything that already exists (tunnel config, 13 CNAMEs, Access apps and policy), so the first apply adopts it instead of recreating it.
  • .github/workflows/cloudflare.yml: tofu plan on PRs, tofu apply on merge to main. State is in the R2 bucket tofu-state, with lockfile-based locking.
  • Renovate: terraform manager enabled. Provider and OpenTofu updates are grouped and not automerged, because merging applies to the live config.
  • CLAUDE.md: how to publish a service and how to put Access in front of it.

Not managed (still in the dashboard)

  • Other DNS records (Microsoft 365, SPF, DKIM, DMARC).
  • The WARP login app.
  • The makstra.xyz zone.

Before merging

  • The plan must be green, and should show only: the tunnel routes changing to traefik:443, makstra.xyz gone, a new "Allow guests" policy, and deemix's policy list.

🤖 Generated with Claude Code

michiel-claude Bot and others added 4 commits October 24, 2026 12:07
Add cloudflare/ with the tunnel's published applications and their
CNAMEs as code. All public hosts now go to https://traefik:443 with the
hostname as SNI, instead of the host IP. makstra.xyz is dropped.

A GitHub Actions workflow plans on PRs and applies on main, with state
in R2. Renovate tracks the provider and OpenTofu without automerge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Import the 13 tunnel CNAMEs, the reusable "Allow users" policy and the
arl, spotizerr and deemix Access apps. Deemix's app-scoped policy becomes
a reusable "Allow guests" policy; its email addresses come from the
ACCESS_GUEST_EMAILS secret, since this repo is public.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The dashboard routes only set origin_server_name, so cloudflared already
verifies Traefik's certificate. Also drop tags = [] from the Access apps;
the imported apps have none.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@michiel-claude
michiel-claude Bot marked this pull request as ready for review October 24, 2026 15:24
@MichielMak
MichielMak enabled auto-merge (squash) October 24, 2026 15:29
@MichielMak
MichielMak merged commit dad60b6 into main Oct 24, 2026
4 checks passed
@MichielMak
MichielMak deleted the cloudflare-iac-tofu branch October 24, 2026 15:31
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