IIRC it isn’t running commands for
IIRC it isn’t running commands for regular builds, it is calling the esbuild JS API
12 Replies
What's the advised way to replicate wrangler behaviour with Cloudflare's Terraform provider?
https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/deployment-bundle/bundle.ts
https://github.com/cloudflare/workers-sdk/blob/main/packages/wrangler/src/dev/use-esbuild.ts
Since you need to take the input typescript and generate the output javascript before passing it to a
cloudflare_workers_script
resource.I'm not sure how to 100% replicate it with the injection.

Couldn't find any mention in the docs on how you are supposed to generate the wrangler-equivalent output that goes along with the Terraform provider.
npx wrangler deploy --dry-run
But also, work on terraform provider is ongoing. Watch out for a much more terraform native way to manage Workers :)What does that mean? 🤔
So far the most dev-friendly way is to use SST (Pulumi wrapper) which handles the bundling for you.
What Cloudflare could do is add a special bundle resource in the Terraform provider that takes your TS file path as input and returns the JS file path as output, and then you can pass that output to the
cloudflare_workers_script
.
Still, not as clean as this.
Another downside of the Cloudflare Terraform provider is that it uploads the code as plain text rather than as a ZIP archive. This means the entire transpiled code — potentially hundreds of thousands to over a million lines — gets printed to stdout during deployment, significantly slowing down the CI. To avoid this, you should mark the resource as sensitive so Terraform skips logging its contents.
This command generates nothing btw. It creates and delete the file, just outputs the size.
Instead you want to place the generated js file into the correct path so it can be picked up by Terraform.I think you need —outdir
ok that works, but you still require a wrangler.jsonc file, which is pointless in a terraform project.
Do you? I can test when I get back, but iirc deploy doesn’t require a config
it does. i was requested lots of things actually
i iteratevly added them till it also asked for a wrangler file


