Skip to content

Commit 55d4b63

Browse files
committed
docs: add new workers improvements changelog
1 parent f4b587c commit 55d4b63

File tree

1 file changed

+127
-0
lines changed

1 file changed

+127
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
---
2+
title: Improvements to the Workers Terraform resources and SDKs
3+
description: Multiple improvements to the Workers Terraform resources and SDKs including fixes for plan diffs, Durable Objects migrations, file uploads, and new Python Workers support.
4+
products:
5+
- workers
6+
date: 2025-07-28
7+
---
8+
9+
The recent [Cloudflare Terraform Provider](https://registry.terraform.io/providers/cloudflare/cloudflare/latest/docs/resources/workers_script) and SDK releases (such as [cloudflare-typescript](https://github.com/cloudflare/cloudflare-typescript)) bring significant improvements to the Workers developer experience. These updates focus on reliability, performance, and adding Python Workers support.
10+
11+
## Terraform Improvements
12+
13+
### Fixed Unwarranted Plan Diffs
14+
15+
Resolved several issues with the `cloudflare_workers_script` resource that resulted in unwarranted plan diffs, including:
16+
17+
- Using Durable Objects migrations
18+
- Using some bindings such as `secret_text`
19+
- Using smart placement
20+
- When the API returned array attribute results in different order
21+
22+
A resource should never show a plan diff if there wasn't an actual change. This fix reduces distracting noise in your Terraform plan.
23+
24+
Available in Cloudflare Terraform Provider 5.8.0.
25+
26+
### Fixed Durable Objects Migration Issues
27+
28+
Resolved an issue in `cloudflare_workers_script` when using Durable Objects migrations failed on the second terraform apply. Configurations like this would work on the first Terraform apply, but fail on subsequent ones:
29+
30+
```tf
31+
resource "cloudflare_workers_script" "my_worker" {
32+
account_id = "123456789"
33+
script_name = "my_worker"
34+
# ...
35+
bindings = [
36+
{
37+
name = "MY_DO"
38+
type = "durable_object_namespace"
39+
class_name = "MyDOClass"
40+
}
41+
]
42+
43+
migrations = {
44+
new_tag = "v1"
45+
new_sqlite_classes = ["MyDOClass"]
46+
}
47+
}
48+
```
49+
50+
This is now fixed.
51+
52+
Available in Cloudflare Terraform Provider 5.8.0.
53+
54+
### Improved File Management
55+
56+
You can now specify `content_file = "worker.js"` and `content_sha256 = filesha256("worker.js")` instead of `content = file("worker.js")`. This prevents the Workers script content from being stored in the state file, which greatly reduces plan diff size and noise. If your workflow synced plans remotely, this will happen much faster.
57+
58+
Available in Cloudflare Terraform Provider 5.7.0.
59+
60+
### Assets Headers and Redirects Support
61+
62+
Fixed the `cloudflare_workers_script` resource to properly support headers and redirects for Assets:
63+
64+
```tf
65+
resource "cloudflare_workers_script" "my_worker" {
66+
account_id = "123456789"
67+
script_name = "my_worker"
68+
content_file = "worker.js"
69+
content_sha256 = filesha256("worker.js")
70+
assets = {
71+
config = {
72+
headers = file("headers")
73+
redirects = file("redirects")
74+
}
75+
# Completion jwt from:
76+
# https://developers.cloudflare.com/api/resources/workers/subresources/assets/subresources/upload/
77+
jwt = "jwt"
78+
}
79+
}
80+
```
81+
82+
Available in Cloudflare Terraform Provider 5.8.0.
83+
84+
### Python Workers Support
85+
86+
Added support for uploading [Python Workers](/workers/languages/python/) (beta) in Terraform. You can now deploy Python Workers with:
87+
88+
```tf
89+
resource "cloudflare_workers_script" "my_worker" {
90+
account_id = "123456789"
91+
script_name = "my_worker"
92+
content_file = "worker.py"
93+
content_sha256 = filesha256("worker.py")
94+
}
95+
```
96+
97+
Available in Cloudflare Terraform Provider 5.8.0.
98+
99+
## SDK Enhancements
100+
101+
### Improved File Upload API
102+
103+
Fixed an issue where Workers script versions in the SDK did not allow uploading files. The SDK now provides an improved Workers files upload API:
104+
105+
```js
106+
const scriptContent = `
107+
export default {
108+
async fetch(request, env, ctx) {
109+
return new Response('Hello World!', { status: 200 });
110+
}
111+
};
112+
`;
113+
114+
const script = await client.workers.scripts.update('my-worker', {
115+
account_id: '123456789',
116+
metadata: {
117+
main_module: 'my-script',
118+
},
119+
files: [
120+
await toFile(Buffer.from(scriptContent), 'my-script', {
121+
type: 'application/javascript+module',
122+
}),
123+
],
124+
});
125+
```
126+
127+
Available in cloudflare-typescript 4.6.0.

0 commit comments

Comments
 (0)