You can now upload Workers with static assets (like HTML, CSS, JavaScript, images) with the Cloudflare Terraform provider v5.11.0, making it even easier to deploy and manage full-stack apps with IaC.
Previously, you couldn’t use Terraform to upload static assets without writing custom scripts to handle generating an asset manifest, calling the Cloudflare API to upload assets in chunks, and handling change detection.
Now, you simply define the directory where your assets are built, and we handle the rest. Check out the examples for what this looks like in Terraform configuration.
You can get started today with the Cloudflare Terraform provider (v5.11.0), using either the existing cloudflare_workers_script resource, or the beta cloudflare_worker_version resource.
Examples
With cloudflare_workers_script
Here’s how you can use the existing cloudflare_workers_script resource to upload your Worker code and assets in one shot.
resource "cloudflare_workers_script" "my_app" { account_id = var.account_id script_name = "my-app"
content_file = "./dist/worker/index.js" content_sha256 = filesha256("./dist/worker/index.js") main_module = "index.js"
# Just point to your assets directory - that's it! assets = { directory = "./dist/static" }}With cloudflare_worker, cloudflare_worker_version, and cloudflare_workers_deployment
And here’s an example using the beta cloudflare_worker_version resource, alongside the cloudflare_worker and cloudflare_workers_deployment resources:
# This tracks the existence of your Worker, so that you# can upload code and assets separately from tracking Worker state.
resource "cloudflare_worker" "my_app" { account_id = var.account_id name = "my-app"}
resource "cloudflare_worker_version" "my_app_version" { account_id = var.account_id worker_id = cloudflare_worker.my_app.id
# Just point to your assets directory - that's it! assets = { directory = "./dist/static" }
modules = [{ name = "index.js" content_file = "./dist/worker/index.js" content_type = "application/javascript+module" }]}
resource "cloudflare_workers_deployment" "my_app_deployment" { account_id = var.account_id script_name = cloudflare_worker.my_app.name
strategy = "percentage" versions = [{ version_id = cloudflare_worker_version.my_app_version.id percentage = 100 }]}What’s changed
Under the hood, the Cloudflare Terraform provider now handles the same logic that Wrangler uses for static asset uploads. This includes scanning your assets directory, computing hashes for each file, generating a manifest with file metadata, and calling the Cloudflare API to upload any missing files in chunks. We support large directories with parallel uploads and chunking, and when the asset manifest hash changes, we detect what’s changed and trigger an upload for only those changed files.
Try it out
- Get started with the Cloudflare Terraform provider (v5.11.0)
- You can use either the existing
cloudflare_workers_scriptresource to upload your Worker code and assets in one resource. - Or you can use the new beta
cloudflare_worker_versionresource (along with thecloudflare_workerandcloudflare_workers_deployment) resources to more granularly control the lifecycle of each Worker resource.
Source: Cloudflare
Latest Posts
- SharePoint: OneDrive and SharePoint – recognize text in PDFs [MC1192663]
![SharePoint: OneDrive and SharePoint – recognize text in PDFs [MC1192663] 2 pexels eberhardgross 1287142](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- Workspaces in Edge: Upcoming migration to improved architecture [MC1192661]
![Workspaces in Edge: Upcoming migration to improved architecture [MC1192661] 3 finger 1697331 1920](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- (Updated) Microsoft Edge for Business and Microsoft 365 Copilot: Introducing “What’s New” page after major updates [MC1188225]
![(Updated) Microsoft Edge for Business and Microsoft 365 Copilot: Introducing “What’s New” page after major updates [MC1188225] 4 pexels pixabay 39828](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)
- Microsoft 365 admin center: Copilot settings – readiness [MC1192665]
![Microsoft 365 admin center: Copilot settings – readiness [MC1192665] 5 pexels frostroomhead 9436715](data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==)

![SharePoint: OneDrive and SharePoint – recognize text in PDFs [MC1192663] 2 pexels eberhardgross 1287142](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-eberhardgross-1287142-150x150.webp)
![Workspaces in Edge: Upcoming migration to improved architecture [MC1192661] 3 finger 1697331 1920](https://mwpro.co.uk/wp-content/uploads/2025/06/finger-1697331_1920-150x150.webp)
![(Updated) Microsoft Edge for Business and Microsoft 365 Copilot: Introducing “What’s New” page after major updates [MC1188225] 4 pexels pixabay 39828](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-pixabay-39828-150x150.webp)
![Microsoft 365 admin center: Copilot settings – readiness [MC1192665] 5 pexels frostroomhead 9436715](https://mwpro.co.uk/wp-content/uploads/2024/08/pexels-frostroomhead-9436715-150x150.webp)
