---
# quotesdb-zzm3
title: Set up infra/ OpenTofu project — providers.tf, terraform.tf, .gitignore for state
status: completed
type: task
priority: critical
created_at: 2026-03-10T23:32:06Z
updated_at: 2026-03-10T23:32:13Z
blocked_by:
- quotesdb-esnq
---
Infrastructure is managed with OpenTofu using the Cloudflare provider. Configuration lives in `infra/`. Resources include a Cloudflare Worker (API), Cloudflare D1 database (bound to the worker), and a Cloudflare Pages project (UI frontend).
Bootstrap the OpenTofu project in `infra/`:
1. Create `infra/providers.tf` — declare the Cloudflare provider with the required version
2. `infra/terraform.tf` — **use the local file backend** (07feaa resolved: local file is the correct choice for this solo project). The local backend is OpenTofu's default, so no explicit `backend` block is needed in `terraform.tf`. The file only needs the `required_providers` block (already partially present in `main.tf` — move it to `terraform.tf` and remove from `main.tf`).
3. Create `infra/.gitignore` — ignore `*.tfstate`, `*.tfstate.backup`, `.terraform/`, `.terraform.lock.hcl`
4. Run `tofu init` to initialise the provider
- State backend is **local file** (resolved by 07feaa). No `backend` block is required — omitting it uses the local default.
- The Cloudflare provider requires an API token — document the expected environment variable (`CLOUDFLARE_API_TOKEN`) in a comment in `providers.tf`, do not hardcode it.
- Every `resource` and `data` block must have a comment explaining its purpose (per CLAUDE.md).
- Note: `infra/main.tf` currently contains the `terraform` block — move it to `infra/terraform.tf` during this task.
Run from the `infra/` directory:
```sh
tofu validate
tofu plan
```
`chore(quotesdb): bootstrap OpenTofu infra project with Cloudflare provider`