You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.5 KiB
Markdown

+++
title = "Define Cloudflare Workers script resource — WASM artifact, D1 binding, environment variables"
priority = 7
status = "todo"
ticket_type = "task"
dependencies = ["25c413", "2d1371", "d0da0b", "07cafb", "efee79"]
+++
<context>
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).
The Cloudflare Worker hosts the `quotesdb-api` binary compiled for the Workers runtime. It is bound to the D1 database and deployed via OpenTofu.
</context>
<goal>
Define the Cloudflare Workers script resource in `infra/worker.tf`:
1. `cloudflare_workers_script` resource (resolve TRIAGE ticket efee79 for correct resource name in current provider version)
2. Set the WASM artifact path (the compiled `api` binary)
3. Bind the D1 database (name must match what workers-rs expects — resolve TRIAGE ticket 07cafb)
4. Set required environment variables
Every block must have a comment.
</goal>
<constraints>
- Resolve TRIAGE ticket efee79 (correct Workers resource name) before writing the resource.
- Resolve TRIAGE ticket 07cafb (D1 chicken-and-egg) before wiring the D1 binding.
- The D1 binding name in the Worker must match the binding name in the workers-rs code.
</constraints>
<validation>
Run from the `infra/` directory:
```sh
tofu validate
tofu plan
```
</validation>
<commit>
`feat(quotesdb): define Cloudflare Workers script resource in OpenTofu`
</commit>