Skip to Content
LYNKORIADocs

Step 5: Zone stack

Apply the shared Cloudflare zone stack — TLS settings, per-environment origin-lock secrets and rules, API cache bypass, www redirect, DMARC and CAA.

Goal: the zone-wide Cloudflare configuration exists, and the per-environment origin-lock secrets that the platform stacks read are in the zone state.

Why a separate stack

Cloudflare allows one zone ruleset per phase (for example one set of request-header rules for the whole zone). Staging and production both need a rule there, so both rules live in one stack, infra/opentofu/zone/, instead of in each environment's stack. It manages:

ResourceWhat it does
Zone settingsSSL Full (strict), Always Use HTTPS, minimum TLS 1.2, TLS 1.3, WebSockets on, Rocket Loader and Email Obfuscation off
random_password.origin_secretOne CF_ORIGIN_SECRET per environment
cloudflare_ruleset.late_transformSets x-lynkoria-origin-secret on requests to each API host (origin lock)
cloudflare_ruleset.cacheBypasses cache for the API hosts
cloudflare_ruleset.redirect + www record301 from www.lynkoria.com to the apex, keeping path and query
DMARC and CAA recordsp=reject DMARC; CAA for Let's Encrypt (media node) and Google Trust Services (App Platform, Pages)

The zone stack has no environment of its own; its workflow runs in the production GitHub environment, so applying it needs production approval.

5.1 Plan

Actions → Infrastructure → Run workflow → stack: zone, action: plan. Approve the production environment when asked. Read the plan: it should only create resources.

If the zone already has hand-made rules in the same phases (a transform rule, cache rule or redirect rule created in the dashboard), the apply fails because the phase's ruleset already exists. Either delete those rules in the dashboard (after copying anything you need into infra/opentofu/zone/main.tf) or import the ruleset; see operate.

5.2 Apply

Run the workflow again with action: apply.

Verify

In the Cloudflare dashboard: SSL/TLS → Overview shows Full (strict); Rules → Overview lists the origin-lock transform rule, the cache rule and the www redirect.

dig +short CAA lynkoria.com
dig +short TXT _dmarc.lynkoria.com

Next: Step 6: First deploy (staging).

On this page