cloudflarecloudflare-workerscloudflare-pagescloudflare-appsterraform-provider-cloudflare

cloudflare_worker_script multiple files


Using CloudFlare web dashboard it's possible to split your code into multiple files using ES module syntax. It works out of the box.

enter image description here

Is it possible to create such configuration using CF Terraform provider and cloudflare_worker_script without JS bundles like webpack?

resource "cloudflare_worker_script" "spainter_script_file_utils" {
  name = "spainter"
  account_id = var.cloud_flare_account_id
  content = file("./workers.js")
  module = true
}

According to their documentation there's no such option


Solution

  • Unfortunately not - the API supports uploading other JavaScript files as additional modules but the Terraform provider hasn't implemented that so it expects you to bundle yourself using Webpack, esbuild, etc