| Add Cloudflare provisioning and deploy tooling e4c5d34 Romain Gautier 18h ago | 1 | # infra |
| 2 | |
| 3 | OpenTofu config for the Cloudflare side of the multihost setup in |
| 4 | `blog/hugo.toml`: one Cloudflare Pages project, custom domain, and DNS |
| 5 | record per language (`mykiwi.blog`, `fr.mykiwi.blog`, `pt.mykiwi.blog`, |
| 6 | `ja.mykiwi.blog`). It assumes `mykiwi.blog` is already a zone in your |
| 7 | Cloudflare account - this only manages what's *inside* that zone. |
| 8 | |
| 9 | Deploys (`wrangler pages deploy public/<lang> --project-name=...`) are out |
| 10 | of scope here; this just provisions the projects and domains deploys land |
| 11 | on. |
| 12 | |
| 13 | ## Setup |
| 14 | |
| 15 | Create a token at https://dash.cloudflare.com/profile/api-tokens (Custom |
| 16 | Token, scoped to the `mykiwi.blog` zone) with `Zone:DNS:Edit`, |
| 17 | `Zone:Zone:Read`, and `Account:Cloudflare Pages:Edit`, then: |
| 18 | |
| 19 | ```sh |
| 20 | export CLOUDFLARE_API_TOKEN=... |
| 21 | ``` |
| 22 | |
| 23 | `cloudflare_account_id` is hardcoded in `variables.tf` (it's not a secret - |
| 24 | just an identifier) - override it with `-var` if you're ever applying |
| 25 | against a different account. |
| 26 | |
| 27 | ## Usage |
| 28 | |
| 29 | From the repo root: |
| 30 | |
| 31 | ```sh |
| 32 | make infra-plan |
| 33 | make infra-apply |
| 34 | ``` |
| 35 | |
| 36 | Or directly, from this directory (`nix develop .#infra` for `tofu`): |
| 37 | |
| 38 | ```sh |
| 39 | tofu init |
| 40 | tofu plan |
| 41 | tofu apply |
| 42 | ``` |
| 43 | |
| 44 | State is local (`terraform.tfstate`, gitignored) - fine for a single person |
| 45 | operating this. If that ever changes, move the backend to something shared |
| 46 | (e.g. an R2 bucket) before a second person touches this. |