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.

28 lines
1.1 KiB
HCL

# Cloudflare Workers script for the quotesdb API.
# Compiled from the `api` binary targeting wasm32-unknown-unknown.
# Build before applying: cargo build --release --bin api --target wasm32-unknown-unknown
resource "cloudflare_workers_script" "api" {
account_id = var.cloudflare_account_id
# Script name used in the Cloudflare dashboard and for routing.
name = "quotesdb-api"
# Compiled Wasm binary — path is relative to the infra/ directory.
content = filebase64("../target/wasm32-unknown-unknown/release/api.wasm")
# D1 database binding — referenced in workers-rs code as `env.DB`.
# Depends implicitly on cloudflare_d1_database.quotesdb via attribute reference.
d1_database_binding {
name = "DB"
database_id = cloudflare_d1_database.quotesdb.id
}
}
# Route that maps quotes.elijah.run/api/* to the quotesdb-api Worker.
# All other requests on the domain are served by Cloudflare Pages.
resource "cloudflare_worker_route" "api" {
zone_id = var.cloudflare_zone_id
pattern = "quotes.elijah.run/api/*"
script_name = cloudflare_workers_script.api.name
}