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.
3.2 KiB
3.2 KiB
| title | status | type | priority | created_at | updated_at |
|---|---|---|---|---|---|
| [TRIAGE] D1 binding chicken-and-egg — D1 ID not known until after apply, but Worker needs it at plan time | completed | task | critical | 2026-03-10T23:32:05Z | 2026-03-10T23:32:05Z |
This is a common Terraform/OpenTofu misconception. Writing database_id = cloudflare_d1_database.db.id in the Worker resource creates an implicit dependency via the attribute reference. OpenTofu:
- Sees that
cloudflare_workers_script.apidepends oncloudflare_d1_database.db(via the.idreference) - Plans D1 creation first; shows Worker
database_idas(known after apply)— this is expected and correct - During
tofu apply: creates D1 first → gets its ID from state → creates Worker with that ID
No two-phase apply, no data source, no explicit depends_on. A single tofu apply provisions both resources in the correct order.
Confirmed from Cloudflare provider v4 source:
- D1 resource:
cloudflare_d1_database— outputsid(String) - Worker resource:
cloudflare_workers_script(plural) —d1_database_bindingblock withdatabase_idandnamefields - This also confirms the answer to TRIAGE efee79: resource name is
cloudflare_workers_script
Concrete HCL:
resource "cloudflare_d1_database" "db" {
account_id = var.cloudflare_account_id
name = "quotesdb"
}
resource "cloudflare_workers_script" "api" {
account_id = var.cloudflare_account_id
name = "quotesdb-api"
content = filebase64("../target/wasm32-unknown-unknown/release/api.wasm")
d1_database_binding {
name = "DB"
database_id = cloudflare_d1_database.db.id # (known after apply) — resolved automatically
}
}
API Worker CI/CD deploy ticket: 57fe5e
1. Research the options above and choose the best approach for this project. 2. Update the `infra/worker.tf` and `infra/d1.tf` resources with the chosen approach. Update ticket a23489 and d0da0b with any constraints. 3. Mark this ticket done with a note on the chosen approach in the body or a comment. `chore(quotesdb): resolve triage — d1-binding-standard-attribute-reference-no-chicken-and-egg`